How is this undeclared?

Posts 1–9 of 9 · Page 1 of 1
How is this undeclared?
I keep on getting this error. And its pissing me off. Dont know how to fix

Code:
1>c:\users\patrick\documents\visual studio 2008\projects\10-1\10-1\employee.h(35) : error C2065: 'age' : undeclared identifier
1>c:\users\patrick\documents\visual studio 2008\projects\10-1\10-1\employee.h(40) : error C2065: 'years' : undeclared identifier
1>c:\users\patrick\documents\visual studio 2008\projects\10-1\10-1\employee.h(45) : error C2065: 'salary' : undeclared identifier
[php]class Employee
{
public:
int GetAge(); //Accessor Functions
int GetYears();
int GetSalary();

void SetAge(int age);
void SetYears(int years);
void SetSalary(int salary);
private:
int itsAge;
int itsYears; //years worked
int itsSalary;
};
//Set Functions --------

void Employee::SetAge(int age)
{
itsAge = age;
}

void Employee::SetYears(int years)
{
itsYears = years;
}

void Employee::SetSalary(int salary)
{
itsSalary = salary;
}
//Get Functions ---------
int Employee::GetAge() //get age of employee
{
return age;
}

int Employee::GetYears() //get years worked
{
return years;
}

int Employee::GetSalary()
{
return salary;
}

[/php]
Your 2 last functions have no access to years and salary. It's in the scope of the other functions.

Edit: Just return the variables you have in your class.. You never declared years and salary..

[php]

int Employee::GetSalary()
{
return itsSalary;
}
[/php]
Quote Originally Posted by Void View Post
Your 2 last functions have no access to years and salary. It's in the scope of the other functions.

Edit: Just return the variables you have in your class.. You never declared years and salary..

[php]

int Employee::GetSalary()
{
return itsSalary;
}
[/php]
And age ;p
Quote Originally Posted by 'Bruno View Post
And age ;p
I skimmed super fast, barely saw anything. |:

Ohai Patrick.
Quote Originally Posted by Void View Post
I skimmed super fast, barely saw anything. |:

Ohai Patrick.
Uhh...Do i know you? Or do you know me through my brother?

I should pay more attention to my book
Quote Originally Posted by Auxilium View Post


Uhh...Do i know you? Or do you know me through my brother?

I should pay more attention to my book
c:\users\patrick\documents\visual studio 2008

your path.. :x
Koreans is just my backup for when im banned for spam :|
Close plox
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us