Thread: question about classes

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    2

    question about classes

    Hey this is an awesome forum, now I am having a problem with a class i am building. I get error C2065 which is the undeclared identifier. My header look like this :
    Sorry nevermind I figure it out. So sorry.
    Last edited by naroken; 04-29-2009 at 10:35 AM. Reason: figure it out

  2. #2
    Registered User
    Join Date
    Apr 2009
    Posts
    2
    I dont know how to delete it after i posted it too. anyone know how to?

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Code:
    void setName(string a)
    {
    	name = a;
    }
    string getName(void)
    {
    	return name;
    }
    void setCalories(int b)
    {
    	calories = b;
    }
    int getCalories(void)
    {
    	return calories;
    }
    void setFat(int c)
    {
    	fatCal = c*9;
    }
    int getFat(void)
    {
    	return fatCal;
    }
    void setTotalCal(int d, int e)
    {
    	d = fatCal;
    	e = calories;
    	totalCal = d + e;
    }
    int getTotalCal(void)
    {
    	return totalCal;
    }
    Those function names need Food:: in front of them.

    Also, the getter functions should be declared const and you should avoid putting a using namespace directive in a header file (explicitly qualify any std namespace objects as necessary).
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Quote Originally Posted by naroken View Post
    I dont know how to delete it after i posted it too. anyone know how to?
    Click on the "edit" button in the post you wish to delete. From there you'll have options to delete a post.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Classes question...
    By Raigne in forum C++ Programming
    Replies: 24
    Last Post: 09-12-2006, 01:46 AM
  2. Replies: 2
    Last Post: 07-28-2006, 02:59 PM
  3. Simple Question about Classes
    By Loctan in forum C++ Programming
    Replies: 5
    Last Post: 06-26-2006, 02:40 AM
  4. Classes and Win32 API, and another Question
    By philvaira in forum Windows Programming
    Replies: 10
    Last Post: 04-10-2004, 07:21 PM
  5. Newbie question about the Private type in classes
    By Ryeguy457 in forum C++ Programming
    Replies: 1
    Last Post: 09-07-2002, 10:17 PM

Tags for this Thread