Click here to Skip to main content
15,884,472 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionerror C2801: 'operator =' must be a member Pin
Mahhouraaaaaa26-Feb-06 5:03
Mahhouraaaaaa26-Feb-06 5:03 
AnswerRe: error C2801: 'operator =' must be a member Pin
Lilith.C26-Feb-06 5:24
Lilith.C26-Feb-06 5:24 
AnswerRe: error C2801: 'operator =' must be a member Pin
Stephen Hewitt26-Feb-06 11:20
Stephen Hewitt26-Feb-06 11:20 
GeneralRe: error C2801: 'operator =' must be a member Pin
PJ Arends26-Feb-06 12:15
professionalPJ Arends26-Feb-06 12:15 
GeneralRe: error C2801: 'operator =' must be a member Pin
Stephen Hewitt26-Feb-06 12:19
Stephen Hewitt26-Feb-06 12:19 
GeneralRe: error C2801: 'operator =' must be a member Pin
Ryan Binns26-Feb-06 17:16
Ryan Binns26-Feb-06 17:16 
GeneralRe: error C2801: 'operator =' must be a member Pin
Stephen Hewitt26-Feb-06 18:10
Stephen Hewitt26-Feb-06 18:10 
GeneralRe: error C2801: 'operator =' must be a member Pin
Ryan Binns26-Feb-06 19:41
Ryan Binns26-Feb-06 19:41 
I completely agree with you, but that's not what I was meaning. In your example, they assignments are evaluated right-to-left, basically the same as
x = (y = (z = 1));
I was meaning to prevent the other way, using parentheses so that the assignments are evaluated left-to-right
((x = y) = z) = 1;
In this case, x is assigned the value 1, and all the rest are not assigned at all. Note the position of the parentheses in my example.

If you make the return value const, you allow the first case, but disallow the second, IMO a desirable thing to do.

Using const also allows the compiler to optimise some situations a bit more.

Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

GeneralRe: error C2801: 'operator =' must be a member Pin
Stephen Hewitt26-Feb-06 19:51
Stephen Hewitt26-Feb-06 19:51 
Jokesome games Pin
FARGORE26-Feb-06 3:04
FARGORE26-Feb-06 3:04 
QuestionHow does the using the address of operator work in Visual C++? Pin
Tom Moore26-Feb-06 2:08
Tom Moore26-Feb-06 2:08 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
BadKarma26-Feb-06 3:15
BadKarma26-Feb-06 3:15 
GeneralRe: How does the using the address of operator work in Visual C++? Pin
Tom Moore26-Feb-06 3:31
Tom Moore26-Feb-06 3:31 
GeneralRe: How does the using the address of operator work in Visual C++? Pin
PJ Arends26-Feb-06 11:13
professionalPJ Arends26-Feb-06 11:13 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
Tom Moore26-Feb-06 3:17
Tom Moore26-Feb-06 3:17 
GeneralRe: How does the using the address of operator work in Visual C++? Pin
Gary R. Wheeler26-Feb-06 5:22
Gary R. Wheeler26-Feb-06 5:22 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
includeh1026-Feb-06 3:19
includeh1026-Feb-06 3:19 
GeneralRe: How does the using the address of operator work in Visual C++? Pin
Tom Moore26-Feb-06 3:34
Tom Moore26-Feb-06 3:34 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
Hamid_RT26-Feb-06 3:48
Hamid_RT26-Feb-06 3:48 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
Tom Moore26-Feb-06 6:10
Tom Moore26-Feb-06 6:10 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
PJ Arends26-Feb-06 11:08
professionalPJ Arends26-Feb-06 11:08 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
David Crow27-Feb-06 3:37
David Crow27-Feb-06 3:37 
QuestionMessage Box being hidden Pin
braveheartkenya26-Feb-06 2:04
braveheartkenya26-Feb-06 2:04 
AnswerRe: Message Box being hidden Pin
includeh1026-Feb-06 3:21
includeh1026-Feb-06 3:21 
GeneralRe: Message Box being hidden Pin
braveheartkenya26-Feb-06 4:52
braveheartkenya26-Feb-06 4:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.