Polymorphism

Hi!

I have one base class Veiculo with two derived classes Veiculo_frigorifico and Veiculo_lona.

Veiculo_lona will have the same atributes of Veiculo but Veiculo_frigorifico will have one extra atribute which is desp_manutencao_fri.

I want to know if to access desp_amnutencao_fri I need to declare get_desp_manutencao_fri in the base class as public and virtual or in the derived class?

Thanks
It all goes in the derived class. That's what makes it special, i.e. different from it's base class.

You'd only add it to the base class if you wanted Veiculo and all its bases classes to do that thing. In this case, you're just specialising (making a special version of) Veiculo, so you wouldn't add it there.
Topic archived. No new replies allowed.