lvalue required as left operand of assignment

What is the wrong here
I have made a class and when i call one of memebers in swich case
give me this error
lvalue required as left operand of assignment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 switch (playerlocation)
	{
	case 1:
		boarddetails.getcname()="Egypt";
		countryprice=300;
		cout<<"you are in "<<boarddetails.getcname()<<endl<<"Price: "<<boarddetails.getcprice()<<endl;
						choose: cout<<"do you want to buy it  (y/n) \n";
						cin>>c;
						if (c=='y')
						{
							playerinformation.getmoney()=(money-countryprice);
						}
						else if (c=='n')
						{
							cout<<"you will roll again \n";
							goto roll;
						}
						else
						{
							cout<<"Error!! please choose from y for yes and n for no \n";
							goto choose;
						}
		break;
You can't assign like this:
boarddetails.getcname()="Egypt";

you want code so you could do something like this:

boarddetails.setcname("Egypt");


And please don't use goto's...
Last edited on
first thx
Why don't use goto's
and is there is something instead???
it makes a lot of bugs in my code
> You can't assign like this:
> boarddetails.getcname()="Egypt";
you could if you return a non-const reference
Topic archived. No new replies allowed.