Just need some things cleared up.

This is a discussion on Just need some things cleared up. within the C++ Programming forums, part of the General Programming Boards category; Because this line: Code: totalIncome = root->worth + totalIncome; adds root->worth (100) to the previous value of totalIncome. Since the ...

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Because this line:
    Code:
    totalIncome = root->worth + totalIncome;
    adds root->worth (100) to the previous value of totalIncome. Since the previous value of totalIncome was "uninitialized garbage", the value of totalIncome afterwards is "100 more than uninitialized garbage".

  2. #17
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Ohh... So C integer variables don't default to 0?

  3. #18
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    No variables default to anything (unless you define them in global scope, which you shouldn't, so never mind about that).

  4. #19
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Ok, thanks ^^

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suggestions for things to study
    By Mastadex in forum Windows Programming
    Replies: 5
    Last Post: 08-18-2008, 09:23 AM
  2. Question about atheists
    By gcn_zelda in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 08-11-2003, 11:50 AM
  3. Funny things happening outside of function
    By drb2k2 in forum C++ Programming
    Replies: 1
    Last Post: 04-08-2003, 02:26 PM
  4. things to think about... [from www.nuclearwastesite.com]
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 11-10-2001, 11:47 PM
  5. Help with these three things...
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 08-26-2001, 07:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21