R
R
Robotex2015-05-08 06:00:19
OOP
Robotex, 2015-05-08 06:00:19

How to use descendant objects in parent class functions in C++?

The point is this. I have two classes: MovableObject and GravitySource , inherited from the previous one (because gravity sources can also move). The MovableObject class has an integrate function that calculates motion parameters based on the list of gravity sources passed to it. But since GravitySource is inherited from this class, I can't pass it to this function. And I would not want to create duplicate parent functions (after all, it must also move and also contain the notorious integrate ). What way out of this situation can be found?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question