print using getter methods

hi everyone

given below is a sample of code i am doing on my assingnment...assuming that my input is correct, can anyone help me print the 6 ID using the employee class using a function.

class Person{
private:
string name;
int ID;

public:
Person();
void setName(string){this->name = name;}
void setID(int){this->ID = ID;}
string getName(){return name;}
string getID(){return ID;}
};


class Employee{
private:
string address;
Person emp;

public:
void setEmployee(string,Person *p){
address = " ";
p = &emp;
}
Person getEmployee(){
return adress;
return p
}
};

const int MAX_SIZE = 6
int main ()
{
Person P1[];

Employee E1[];

int x;
for (int i=0;i<MAX_SIZE;i++)
{
x = i;
P1.setID(x);
address = "aaa";
E1.setEmployee(address,P1);
}
.
.
.//print id here
.
.
return 0;
}

looking forward to your assistance...
regards
Here's a clue

1
2
string getName(){return name;}
string getID(){return ID;}


these are called accessor function

http://classes.mst.edu/compsci1570/mutators.htm

you can access them and display whatever you want

ps: please use code tags : http://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.