So im supposed to...
1. Create a small program with vector of pointers to Employee objects.
2. ask user how many employee objects they want
3. create employee objects
4. assign their pointers to the vector
5. Display the vector
what I have is....
1 2 3
Cout << “how many employees?” << endl;
Cin >> howMany;
Employee employee(string name, int salary);
from here im just stumped!
if someone could give me some help I would really appreciate it!
Employee( string name, int salary ) : m_name(name), m_salary(salary)
I'm not going to write all the code for you but here is a start
1 2 3 4 5 6 7 8
vector< Employee * > employees;
for( int i=0; i < howMany; i++ )
// You need to get the name and salary for each employee here
// and pass it into the constructor
employees.push_back( new Employee( "", 0 ) );
Looks fine to me. Although the creation of an employee called one seems to be pointless - you don't do anything with it, and the object will fall out of scope and be destroyed at the end of each iteration of the loop.