Quick help req, Passing a inherited class from base class issues

Started by
2 comments, last by BaneTrapper 10 years, 4 months ago

Hello.

I got brain freeze or long week to say it better and i cant just remember how did i do the following:

class tire
{
...
};
 
class car : public tire
{
...
};
 
void RemoveTire(tire* TheTire)
{
...
}
 
int main
{
car objCar;
RemoveTire(objCar);//This line right here i just cant get it intro my head how did i do it like that
}
Advertisement

Hello.

I got brain freeze or long week to say it better and i cant just remember how did i do the following:


class tire
{
...
};
 
class car : public tire
{
...
};
 
void RemoveTire(tire* TheTire)
{
...
}
 
int main
{
car objCar;
RemoveTire(objCar);//This line right here i just cant get it intro my head how did i do it like that
}

Your RemoveTire function takes a pointer to a tire. You need to pass the address of objCar for it to compile.

Edit: That said, that class inheritance doesn't make a lot of sense to me. A car is a sub-class of tire?

Hello to all my stalkers.

RemoveTire(&objCar);

You need more than quick help though. This line:

class car : public tire

says a car IS A tire. And anything that applies to a tire should also apply to a car. This is clearly wrong.

EDIT: You want composition instead, a car HAS A tire (or more than one).

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Well i changed the subjest in order to get a easy answer and not type walls of text...

I am not using that in the sense you think i do not need a car inheriting from tire at all...

Function that has X as parameter, Object that has X inherited, how to pass from the Object intor Function the parameter X...

I dig thrue my project, but i cant find it, also cant remember sad.png .

EDIT:
I rememberd, thanks on attempts.

This topic is closed to new replies.

Advertisement