Re: Making a hauler

[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

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[0] = new Hauler(ID, Address, Direction);

: Trucks is defined as:
: TowTruck* Trucks[10];

: 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.

Try this:

Trucks[0] = 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.

Follow Ups:

Post a Followup




Optional Link URL:
Link Title:
Optional Image URL:

[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]