Oct 21, 2010 at 9:41am
e.g.
class emp {
private:
......
......
public
void setEmpSalary(double);
void setEmpName(string);
}
main() {
char stores[5];
int i;
for (i = 0; i < 5; ++i) {
emp employee;
employee.setEmpSalary(100.50);
employee.setEmpName("Ghost");
//////
my qns is how do i set per employee object which has the information of salary and its name into the an array?
Please advise. Thank you.
Oct 21, 2010 at 9:43am
use vector..
vector<emp> employees;
Oct 21, 2010 at 9:45am
if i can only use array? Any advise?
Oct 21, 2010 at 9:49am
emp employee[5];
employee[0].setEmpName("GHOST");
...............
Oct 21, 2010 at 9:52am
can i do it this way?
store[0] = employee; (as in store the class object that contain the information of name and salary?)
Oct 21, 2010 at 9:55am
must be of same type or object...
emp employee[5];
emp manager;
employee[0] = manager;