C++ Question

Nolf-JobNolf-Job Inside each and every one of you!
edited April 2004 in Internet & Media
So I need to create a class and then follow these guidelines
>
Details about the member functions (methods) are as follows:
A. There are no constructors
B. setId() is used to store the id in an Employee object
C. setName() is used to store the name in an Employee object
D. setSalary() is used to store the salary in an Employee object
E. getId() is used to retrieve the id from an Employee object
F. getName() is used to retrieve the name from an Employee object
G. getSalary() is used to retrieve the salary from an Employee object


--Here is my class--
class Employee
{
private:
int id;
string name;
double salary;
public:
void setId(int num)
{id = num;}
void setName(string employeeName)
{name = employeeName;}
void setSalary(double money)
{salary = money;}
void getId()
void getName();
void getSalary();

};

----And here is one of the functions---
void displayEmp(const Employee& emp){
cout << endl << "Name ID Salary: "
<< emp.getName() << " "
<< emp.getId() << " "
<< emp.getSalary();
}

---And my question--
I can't figure out what I need to put for the three "get" functions in my class. Any help?

Comments

  • hoojhooj Bournemouth, UK
    edited April 2004
    dont really know much about c++ but should be something like the following

    int getId(){
    return id;
    }
  • Nolf-JobNolf-Job Inside each and every one of you!
    edited April 2004
    I tried that before too, and i get this error h:\CPT 267\wk8\LAB04\LAB04\Lab04p1.cpp(71): error C2662: 'Employee::getName' : cannot convert 'this' pointer from 'const Employee' to 'Employee &'
  • hoojhooj Bournemouth, UK
    edited April 2004
    int getId() const{
    return id;
    }
  • Nolf-JobNolf-Job Inside each and every one of you!
    edited April 2004
    thanks hooj, that worked
Sign In or Register to comment.