This is topic C++ suddenly became the evil wicked witch of the North. in forum Books, Films, Food and Culture at Hatrack River Forum.


To visit this topic, use this URL:
http://www.hatrack.com/ubb/main/ultimatebb.php?ubb=get_topic;f=2;t=047127

Posted by Blayne Bradley (Member # 8565) on :
 
return stack[++top] = newItem; will increment top before returning the stack value.

[Eek!] [Angst]
 
Posted by mr_porteiro_head (Member # 4644) on :
 
Do you know the difference between ++top and top++?
 
Posted by King of Men (Member # 6684) on :
 
Yes, well? That's what the language description says. Honestly, there are plenty of reasons C++ is evil, but having increment operators that do what the spec says they'll do is not one of them. That's rather an example of what we call an eye-dee-ten-tee error.
 
Posted by Will B (Member # 7931) on :
 
stack[top++] = newItem; is pretty conventional, and for obvious enough reasons.
 
Posted by Blayne Bradley (Member # 8565) on :
 
i'm used to a somewhat more complicated method.
 
Posted by Bokonon (Member # 480) on :
 
I prefer "&stack + (sizeof(newItem) * top) = newItem;", myself. Pointer arithmetic is nifty*

[Wink]

(Yes, I know I've probably screwed that up, my C/C++ is rusty. You get the idea, I hope)

-Bok

* For all definitions of nifty that imply a certain sort of masochism.
 
Posted by MrSquicky (Member # 1802) on :
 
I also get upset when the language works exactly as it is described. For example, did you know that if...then...else control structures won't let you execute both code blocks one right after the other, but rather selects which code block to execute based on the truth value of the boolean expression provided in the if clause. Bastards!
 
Posted by BlackBlade (Member # 8376) on :
 
How am I the first person to note that the witch of the north is the good one, while its her western counter part who is evil? Just look at her name,(Glenda the Good!)

Glenda could probably help you out with your C++, she's got some pretty crazy power.

Learn literature/pop culture along with your tech.
 
Posted by King of Men (Member # 6684) on :
 
I believe he's referring to Canada as "The North". Which doesn't make much sense, since the C++ spec is the same everywhere, but whatever.
 


Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2