Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Feb 2012
Offline Last Active Jan 21 2013 03:58 PM

Topics I've Started

for and while inifite loops

28 December 2012 - 04:22 PM

So I noticed that both for and while loops have a infinite loop option, is there any difference between them? 

Getting something to run code again.

16 March 2012 - 07:55 PM

Say I have a switch statement with certain parameters, but when someone doesn't input what it ask's, I want the default to go back to the switch statement instead of making another one.

Declaring Variables outiside int main

06 March 2012 - 04:13 PM

Just asking if it is possible to declare variables outside int main, any functions and outisde classes?

Wierd Code 0.o

20 February 2012 - 06:09 PM

So today I was getting into reading more on classes and I read on classes in seperate files and it was like Myclass::Myclass or something

so.. what does the "::" mean??

Switch and If/else C++

19 February 2012 - 09:12 AM

So, yesterday I started making a geuss the number game and there was a problem that if you geussed it right it would show a loss.I tried today of using classes for losses instead of a bunch of code in the if and else curly brackets. Now even with class's I still get an error. Is there some kind of prblem with my if statement or is there a problem when an if statement is in a switch?
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;
class Win{
	    void setWin(string x){
		    win = x;
	    string getWin(){
		    return win;
	    string win;
class Loss{
	    void setLoss(string z){
		    loss = z;
	    string getLoss(){
		    return loss;
	    string loss;
int main()
  int number;
  char gn;
  char dif;
  Win wo;
  wo.setWin("You Won!");
  Loss lo;
  lo.setLoss("You Lost, the number was ");
    cout << "Welcome to Guess The Number 3.0" << endl;
    cout << "Please choose your difficluty. E = Easy M= Medium H = Hard" << endl;
    cin >> dif;
		    case 'e':
		    case 'E':
				 number = 1+(rand()%10);
				    cout << "Guess a number beetween 1 and 10" << endl;
				    cin >> gn;
				    if(gn == number){
						 cout << wo.getWin() <<endl;
					    lo.getLoss() << number << endl;

This is 1/3 of the whole program.