Thread: Class declaring an int

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    192

    Class declaring an int

    hi new to C++
    basically i have a header.h file that holds a
    Code:
    class foo
    { 
    public:
    int takeTime(int var);
    int time;
    }
    then in my header.c
    Code:
    int takeTime(int var){
    time = 1230;
    return 0;
    }
    y doesnt the time variable show up when i compile its in the class and it can see teh function call but cant see the variable?

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    109
    What do you mean 'see'? Try to type properly also. It's easier to understand what you are asking when you do.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    Your example shouldn't even compile. takeTime in header.c will not be a part of the class foo at all. Use foo::takeTime when you define functions outside the class.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to combine these working parts??
    By transgalactic2 in forum C Programming
    Replies: 0
    Last Post: 02-01-2009, 08:19 AM
  2. Replies: 8
    Last Post: 03-10-2008, 11:57 AM
  3. Replies: 26
    Last Post: 11-30-2007, 03:51 AM
  4. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  5. Declaring an instance of a class inside a class
    By nickodonnell in forum C++ Programming
    Replies: 4
    Last Post: 10-01-2005, 11:46 PM