Discussion:
Wonder why...
(too old to reply)
Andre
2008-07-22 15:44:10 UTC
Permalink
I wonder why the compiler won´t let me do things like:

================
...
if (object->boolProperty = anotherObject->boolProperty)
...
================

It will give the error:

E2492: Properties may only be assigned using a simple statement, e.g.
"prop = value;"
Rene
2008-07-22 15:54:19 UTC
Permalink
Post by Andre
================
...
if (object->boolProperty = anotherObject->boolProperty)
...
================
E2492: Properties may only be assigned using a simple statement, e.g.
"prop = value;"
You have made an error that I have made often as well. And it has sometimes
taken me a lot of time before I saw what I did wrong. I will give You a
hint: = is not meant to check whether two things are the same. It is the
assigment operator. If You want to check whether one value is the same as
another, You need two add one more character. Just like in <= or >=.

Yours sincerely,
Rene

P.S. If You still don't see it, the answer is a bit below.










if (A==B)
{
cout << "Now You know what to do! ;-)";
}
Vladimir Stefanovic
2008-07-22 16:44:43 UTC
Permalink
Post by Rene
You need two add one more character.
I think that Andre indeed thought of assignement,
not a comparison.
--
Best Regards,
Vladimir Stefanovic
Rene
2008-07-22 22:46:36 UTC
Permalink
Post by Vladimir Stefanovic
Post by Rene
You need two add one more character.
I think that Andre indeed thought of assignement,
not a comparison.
In that case my reply is completely useless. Pity, I was so happy that
finally I, being a newbie and having been helped in this group several
times, was capable of helping someone else as well.

Yours sincerely,
Rene

Benjamin Pratt
2008-07-22 21:51:23 UTC
Permalink
Post by Andre
if (object->boolProperty = anotherObject->boolProperty)
If you're actually trying to assign a value and test for true in a
single line, then you can instead do:

if( (object->boolProperty = anotherObject->boolProperty) != false)

to avoid the error message...at least that's true for native types; I'm
not entirely sure for __properties...
Loading...