Thread: How Does Increment Operators Work...??

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #27
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    hk_mp5kpdw already answered you in the first reply: it is undefined behaviour. You could get 15, you could get 17, or you could get your computer blown up.

    EDIT:
    Though I am assuming that you actually fix the statement to become:
    Code:
    a = (b++) + (--b) + (b--) + b;
    or at least:
    Code:
    a = (b++) + (- - b) + (b--) + b;
    Last edited by laserlight; 02-06-2008 at 09:51 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  2. Problems in getting OpenGL to work
    By zonf in forum C Programming
    Replies: 5
    Last Post: 02-13-2006, 04:48 AM
  3. Why won't my OpenGL work?
    By Raigne in forum C++ Programming
    Replies: 7
    Last Post: 11-26-2005, 11:53 AM
  4. Developers Wanted
    By Quasicom in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 08-24-2005, 12:46 AM
  5. Overloading Operators
    By Strahan in forum C++ Programming
    Replies: 4
    Last Post: 09-07-2001, 11:39 AM