Hi!
I have a base class called vehicle and two sub classes Car and Bike.
I have a handler file that has a couple of functions like addVehicle,showAll, showCars and showBikes.
Now to my problem, when the bikes are presented it looks like this.
Model: BMW Year: 2005 Cost: 2000
Model: Kawasaki Year: 2030 Cost: 40000
and so on....
At the end I want all costs to be added together and presented with a total cost.
So I've written something like this
1 2 3 4 5 6 7
|
for(int i=0;i<this->nrOfPresents;i++)
{
if(typeid(*this->prsnt[i])==typeid(Company))
{
this->prsnt[i]->present();
}
}
|
but when I try to access my function that returns the price for each bike it cant see it it only shows me the functions in the base class and not any function from the sub classes.
If I didn't use inheritance I would have done something like this
1 2 3 4
|
for(int i=0;i<this->nrOfPresents;i++)
{
int totalCost+=this->prsnt[i]->getCost();
}
|
How do I make this work, something tells me it should be easy?
Best Regards Ogward