I have a virtual C++ method that I'm defining in a .h file and implementing in a .cc file. Should the implementation in the .cc file be marked virtual, or just the declaration in the .h file? E.g., my header has:
virtual std::string toString() const;
The method is implemented in my .cc:
std::string
MyObject::toString() const {
[implementation code]
}
Should the implementation be marked virtual, or is the above code OK? Does it matter?