|
-
Feb 12th, 2001, 09:07 PM
#1
Thread Starter
Registered User
Hello everyone again, i still can't figure out this problem!
i am getting these compiler errors!
here is my .hpp file with the class interface:
Code:
#include <iostream.h>
class Employee
{
public:
void SetAge(int EAge);
void SetyearsOfService(int yOf);
void SetSalary(int Money);
int GetAge();
int GetyearsOfservice();
int GetSalary();
private:
int age;
int yearsOfservice;
int Salary;
};
here is the .cpp file with the implemnation of the class methods:
Code:
#include "Employee.hpp"
//function implamenation (can't spell) :P
void Cat::SetAge(int EAge)
{
age = EAge;
}
//
void Cat::SetyearsOfService(int yOf)
{
yearsOfservice = yOf; //
}
void Cat::SetSalary(int Money) //
{
Salary = Money;
}
int Cat::GetAge()
{
return age;
} //
int Cat::GetyearsOfservice() //
{
return yearsOfservice;
}
int Cat::GetSalary()
{
return Salary;
}
int main() {
Employee Cory;
Cory.SetAge(15);
Cory.SetSalary(100000);
Cory.GetyearsOfservice(4);
cout << Cory.GetAge << endl;
cout << Cory.GetSalary << endl;
cout << Cory.GetyearsOfservice << endl;
return 0;
}
and if u want the full list of errors, i'll post it in the next message! 
thanks for listening
-
Feb 12th, 2001, 09:12 PM
#2
Lively Member
replace the "Cat" with "Employee" for each of the functions used in the class. And when you are calling some of the functions, you are passing parameters to them when it they have none.
-
Feb 12th, 2001, 09:26 PM
#3
Thread Starter
Registered User
waht do u mean, which functions am i doing this?
hah i can't belive i put Cat insteed of employee, anyways..i fixed that, i still got 31 errors..and what do u mean what fucntions did i write which shoudln't have any paremeters passed ?
-
Feb 12th, 2001, 09:34 PM
#4
Lively Member
Sorry, I should have been more specific. In your code, you put...
Code:
Cory.GetyearsOfservice(4);
but when you declared it, you didn't have any parameters.
Also, you need to add a parenthesis at the end of every function. So replace...
Code:
cout << Cory.GetAge << endl;
cout << Cory.GetSalary << endl;
cout << Cory.GetyearsOfservice << endl;
return 0;
with...
Code:
cout << Cory.GetAge() << endl;
cout << Cory.GetSalary() << endl;
cout << Cory.GetyearsOfservice() << endl;
return 0;
-
Feb 12th, 2001, 09:41 PM
#5
Thread Starter
Registered User
Hey thanks alot!
thanks that and a typo of a variable fixed everything!
-
Feb 14th, 2001, 10:19 AM
#6
Monday Morning Lunatic
In your .hpp file I would suggest putting some protection against multiple-inclusion into it, such as:
Code:
#ifndef __EMPLOYEE_HPP__
#define __EMPLOYEE_HPP__
// Code here
#endif
Otherwise if you include the file from two other source files the linker (I think) will choke
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|