Posted by Jon on November 29, 2001 at 07:27:48:
In Reply to: Making a hauler posted by Chris on November 28, 2001 at 22:17:18:
: I'm trying to make a hauler object and put it in my array of towtruck pointers by doing this:
: Trucks = new Hauler(ID, Address, Direction);
: Trucks is defined as:
: TowTruck* Trucks;
: The constructor i am trying to access is the one TowTruck has....but when i make this call i get an error saying "Hauler::Hauler : no overloaded function takes 3 parameters"
: So i assume its not looking for the constructor in the base class...but i have all the inheritance set up correctly...
: What am i screwing up?
You are screwing up because the hauler constructer is not allowed to access the private data members of the parent type, TowTruck.
Look at slide 14 on Inheritance in the notes. Basically, what you wanna do it have the constructer of the hauler accept a generic tow truck as a parameter.
Trucks = new Hauler(TowTruck(ID, Address, Direction))
look at the notes Inheritance 14 to find out how to write the Hauler constructor properly. Also, look at slide 15 to see the problem you were having.
Post a Followup