c++11 has introduced the new override keyword for explicitely declaring that a method is overriding a virtual method.
With c++11 for documentation purposes in derived classes there is no need to put a virtual keyword in front of overriden virtual method anymore as override already documents it.
How do you keep the documentation style in .cpp files of derived classes ?
// base.hpp
class A
{
public:
virtual int someMethod();
};
And in derived like this, as override already documents that the method is virtual
// derived.hpp
class B : public A
{
public:
int someMethod() override;
};
in derived.cpp
//virtual <----- DO YOU STILL KEEP IT LIKE THIS ?
int B::someMethod()
{
...
}
Aucun commentaire:
Enregistrer un commentaire