Hi,
I've created a class SetOfPersons which holds an array of Person object pointers (Person ** elements
I've also created a subclass - SetOfAdults which inherits from SetOfPersons. Also I have an Adult class that inherits from Person.
In my main method I have:
Adult *a1 = new Adult("Name", 98); //constructor is (name, age).
SetOfAdults adults;
adults.add(*a1);
Later I try:
Adult & a2 = adults.getNextElement();
The compiler gives me:
cannot convert from 'class Person' to 'class Voter &'
Where am I going wrong? Should the SetOfPersons be modified?
Thanks,
jimbo.
I've created a class SetOfPersons which holds an array of Person object pointers (Person ** elements
I've also created a subclass - SetOfAdults which inherits from SetOfPersons. Also I have an Adult class that inherits from Person.
In my main method I have:
Adult *a1 = new Adult("Name", 98); //constructor is (name, age).
SetOfAdults adults;
adults.add(*a1);
Later I try:
Adult & a2 = adults.getNextElement();
The compiler gives me:
cannot convert from 'class Person' to 'class Voter &'
Where am I going wrong? Should the SetOfPersons be modified?
Thanks,
jimbo.