C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 04-29-2009, 10:17 AM   #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
naroken is offline   Reply With Quote
Old 04-29-2009, 10:35 AM   #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?
naroken is offline   Reply With Quote
Old 04-29-2009, 10:36 AM   #3
Registered User
 
hk_mp5kpdw's Avatar
 
Join Date: Jan 2002
Location: Northern Virginia/Washington DC Metropolitan Area
Posts: 2,787
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).
__________________
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
--Charles Babbage, 1792-1871

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
hk_mp5kpdw is offline   Reply With Quote
Old 04-29-2009, 10:37 AM   #4
Registered User
 
hk_mp5kpdw's Avatar
 
Join Date: Jan 2002
Location: Northern Virginia/Washington DC Metropolitan Area
Posts: 2,787
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.
__________________
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
--Charles Babbage, 1792-1871

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
hk_mp5kpdw is offline   Reply With Quote
Reply

Tags
class, classes, error c2065

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classes question... Raigne C++ Programming 24 09-12-2006 01:46 AM
Simple question about classes (destructor and operator overloading) Loctan C++ Programming 2 07-28-2006 02:59 PM
Simple Question about Classes Loctan C++ Programming 5 06-26-2006 02:40 AM
Classes and Win32 API, and another Question philvaira Windows Programming 10 04-10-2004 07:21 PM
Newbie question about the Private type in classes Ryeguy457 C++ Programming 1 09-07-2002 10:17 PM


All times are GMT -6. The time now is 07:04 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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