Using the struct definition given below...

struct A 

Approach #1:

struct B : public A 



Approach #2:

struct B : public A 



Can there be any distinction between both of these methods to override the hello function?

They're the identical. There's no distinction between them apart from that the very first approach requires more typing and it is potentially clearer.

The 'virtualness' of the function is propagated unconditionally, however a minumum of one compiler I personally use will generate an alert when the virtual keyword sits dormant clearly, so you might want to utilize it if perhaps to help keep the compiler quiet.

From the purely stylistic point-of-view, such as the virtual keyword clearly 'advertises' the very fact towards the user the function is virtual. This is vital that you anybody further sub-classing B without needing to check A's definition. For deep class hierarchies, this becomes particularly important.

Adding the "virtual" keyword is nice practice because it enhances readability , but there is no need. Functions declared virtual within the base class, and getting exactly the same signature within the derived courses are considered "virtual" automatically.

There's no difference for that compiler, whenever you write the virtual within the derived class or omit it.

But you have to consider the base class to obtain these details. Therfore I would suggest to include the virtual keyword also within the derived class, if you wish to show towards the human this function is virtual.