FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » C++ suddenly became the evil wicked witch of the North.

   
Author Topic: C++ suddenly became the evil wicked witch of the North.
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
return stack[++top] = newItem; will increment top before returning the stack value.

[Eek!] [Angst]

IP: Logged | Report this post to a Moderator
mr_porteiro_head
Member
Member # 4644

 - posted      Profile for mr_porteiro_head   Email mr_porteiro_head         Edit/Delete Post 
Do you know the difference between ++top and top++?
Posts: 16551 | Registered: Feb 2003  |  IP: Logged | Report this post to a Moderator
King of Men
Member
Member # 6684

 - posted      Profile for King of Men   Email King of Men         Edit/Delete Post 
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.
Posts: 10645 | Registered: Jul 2004  |  IP: Logged | Report this post to a Moderator
Will B
Member
Member # 7931

 - posted      Profile for Will B   Email Will B         Edit/Delete Post 
stack[top++] = newItem; is pretty conventional, and for obvious enough reasons.
Posts: 1877 | Registered: Apr 2005  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
i'm used to a somewhat more complicated method.
IP: Logged | Report this post to a Moderator
Bokonon
Member
Member # 480

 - posted      Profile for Bokonon           Edit/Delete Post 
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.

Posts: 7021 | Registered: Nov 1999  |  IP: Logged | Report this post to a Moderator
MrSquicky
Member
Member # 1802

 - posted      Profile for MrSquicky   Email MrSquicky         Edit/Delete Post 
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!
Posts: 10177 | Registered: Apr 2001  |  IP: Logged | Report this post to a Moderator
BlackBlade
Member
Member # 8376

 - posted      Profile for BlackBlade   Email BlackBlade         Edit/Delete Post 
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.

Posts: 14316 | Registered: Jul 2005  |  IP: Logged | Report this post to a Moderator
King of Men
Member
Member # 6684

 - posted      Profile for King of Men   Email King of Men         Edit/Delete Post 
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.
Posts: 10645 | Registered: Jul 2004  |  IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

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