class A
{
virtual void funcion()
{
//...
}
}
class B:public A
{
//1:virtual void function();
//2:void function();
}
What's the differences between the 1 and 2 ? Or it is the same?
They're the same. A function declared virtual in the base class is virtual all through the inheritance chain.
I find it useful to add the virtual for clarity (more often than not, the classes aren't in the same file).
They're exactly the same. Once a function has been declared virtual in a base class, any class that inherits from it will also have that function declared virtual by default.