(Sorry if this question was asked here before, but I searched for it for hours now, and couldn't find anything. Someone said that what I want is possible, and he told me how, I did as he said yet it is total failure.)
First of all, here is a class diagram for the easier presenting of the question.
Then the code which doesn't do what I want:
int main()
{
Employee jack("Jack", 100);
People guys(jack); // using push_back
...
}
So when this happens, as the debug mode shows, guys[0] will only have a name
, no salary
. Is it even possible, to an object in the vector to have other members than name
? Or my only choice is to make an Employee
vector?
Edit: Person
is virtual by the way.