JUCE example project and virtual methods


#1

Maybe I’m just missing something here, but why aren’t the derived classes in the JUCE example project using the virtual keyword?

For example, take JUCEHelloWorldApplication::initialise. It’s just declared as “void” in the sample code. But, JUCEApplication::initialise is declared as “virtual void”.

Is this some rule of virtual inheritance that I don’t know? What happens if a subclass declares a method as nonvirtual when there’s already a method with the same name in the parent class that is virtual?

It all seems to work okay, so I’m probably just confused.


#2

the virtual keyword sticks to the function in the derived class, as you could not possibly make it ‘un-virtual’ [not that it would make any amount of difference if you could] so you just don’t need it. it’s nice to put it in as a hint to people who may derive classes further from that, but it’s not necessary.


#3

Thanks - I didn’t realize that.