Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

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

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 BaneTrapper   Members   

1530
Like
0Likes
Like

Posted 22 December 2013 - 02:17 PM

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
}


#2 Lactose   GDNet+   

10813
Like
2Likes
Like

Posted 22 December 2013 - 02:25 PM

 

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?


Edited by CoreLactose, 22 December 2013 - 02:28 PM.

Hello to all my stalkers.

#3 Paradigm Shifter   Members   

5832
Like
6Likes
Like

Posted 22 December 2013 - 02:26 PM

*
POPULAR

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


Edited by Paradigm Shifter, 22 December 2013 - 02:28 PM.

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

#4 BaneTrapper   Members   

1530
Like
0Likes
Like

Posted 22 December 2013 - 07:45 PM

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.


Edited by BaneTrapper, 22 December 2013 - 08:33 PM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.