3 Replies - 462 Views - Last Post: 04 October 2012 - 09:04 AM Rate Topic: -----

#1 sunnyxm  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 24-August 12

error "expression must be modifiable value"

Posted 04 October 2012 - 08:53 AM

This is the part of the code where I get that error:

cout << "Tempterature: " << setw(18)  << "\t" << e[count].getTemp() << endl;
		if ( e[count].getTemp () == 500 )
		{
			e[count].getTemp () = "not known!";
		}



I get the error "expression must be modifiable value" when I try to change e[count].getTemp() to "not known".
I know it is because of the array. However, this part of code is read from a file and to read all the values the
program has to read it in using an array.Is there any way to make this work?

Is This A Good Question/Topic? 0
  • +

Replies To: error "expression must be modifiable value"

#2 sunnyxm  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 24-August 12

Re: error "expression must be modifiable value"

Posted 04 October 2012 - 09:02 AM

Any help or guidance is appreciated :smile2:
Was This Post Helpful? 0
  • +
  • -

#3 AKMafia001  Icon User is offline

  • </code.in.dream>

Reputation: 187
  • View blog
  • Posts: 624
  • Joined: 11-June 11

Re: error "expression must be modifiable value"

Posted 04 October 2012 - 09:04 AM

Why don't you overload the subscript [] operator? It would be easy that way to assign and access the value.

To figure out this error, you have to provide how the getTemp() is implemented and what it returns.
Was This Post Helpful? 0
  • +
  • -

#4 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2101
  • View blog
  • Posts: 3,204
  • Joined: 21-June 11

Re: error "expression must be modifiable value"

Posted 04 October 2012 - 09:04 AM

Apparently the return type of getTemp is one that you can't assign to, i.e. it's either a const-reference or no reference at all.

Also even if the getTemp method returned a reference, you probably won't be able to assign a string literal to it since it seems to return an int. So that really doesn't make sense.

PS: Don't bump your thread after only 8 minutes (or at all, really).

This post has been edited by sepp2k: 04 October 2012 - 09:07 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1