Thread: variable being reset

  1. #1
    Registered User
    Join Date
    Aug 2005

    variable being reset

    I have a class. Within the class in the private section, I have a value (current_position) defined as an int. I have a private function that uses this value. Ahhh, goes like this;

    Public class function is called. (PCF)

    PCF calls the Private class function (VCF).

    This private function contains a loop that calls another private function and the int variable is modified within that 2nd private function. NOW, AS THIS VARIABLE is defined within the private base section, not within the private function, it SHOULD be used globally within the class, i would think.

    Problem is, the 2nd private function sets it to a new number but the next time through the loop, the variable is back at its original value.


    NEVER MIND. Global variable and the variable name defined in the called function were the same. oops.
    Last edited by FoodDude; 09-15-2005 at 11:31 AM.

  2. #2
    Registered User
    Join Date
    Nov 2002
    Sounds like you are confusing private with static as well...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 09-27-2005, 12:49 PM
  2. static variable
    By Roaring_Tiger in forum C Programming
    Replies: 9
    Last Post: 04-01-2003, 01:12 PM
  3. Need help
    By awkeller in forum C Programming
    Replies: 2
    Last Post: 12-09-2001, 03:02 PM
  4. Incrementing time and calendarfrom 1999-2000
    By Karma in forum C++ Programming
    Replies: 1
    Last Post: 12-03-2001, 02:48 PM
  5. Why does my variable keep changing to -858993460?
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 10-11-2001, 10:10 AM