cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
This may be a stupid question.But still
This may be a stupid question.But still if someone can answer
May 18, 2012 at 4:48am UTC
preetgill
(6)
if this
a = 2 + (b = 5); and
this
a = b = c = 5;
expressions are right and working fine.
Then why following is not working:
int a,b;
b=2;
a=2+b=5;
May 18, 2012 at 5:07am UTC
JLBorges
(13770)
The assignment operator
=
is right-associative, has a lower precedence than the binary
+
operator,
and
2+b
is not an l-value. (assuming that b is not an object of a user-defined type).
a = ( (2+b) = 5 ) ;
// fully parethesized
May 18, 2012 at 5:12am UTC
preetgill
(6)
Ok Ok.
It is because
2+b is not l-value. Got it got it. thx
Topic archived. No new replies allowed.