Refer to this: C++ "virtual" keyword for functions in derived classes. Is it necessary? - Stack Overflow (http://stackoverflow.com/questions/4895294/c-virtual-keyword-for-functions-in-derived-classes-is-it-necessary)
I think this is a good way. But currently it was not in our Coding style - CodeBlocks (http://wiki.codeblocks.org/index.php?title=Coding_style)
Index: plugins/codecompletion/parser/parserthreadedtask.h
===================================================================
--- plugins/codecompletion/parser/parserthreadedtask.h (revision 8991)
+++ plugins/codecompletion/parser/parserthreadedtask.h (working copy)
@@ -17,7 +17,7 @@
{
public:
ParserThreadedTask(Parser* parser, wxMutex& parserCS);
- int Execute();
+ virtual int Execute();
private:
Parser* m_Parser;
Any comments?
Any comments?
Code to the style of the old code at the place you're adding the function and everything will be good :)
Oh, I can't understand this sentence, can you be more specific?
I mean, the base class have the style:
class cbThreadedTask
{
public:
/// cbThreadedTask ctor
cbThreadedTask();
/// cbThreadedTask dtor
virtual ~cbThreadedTask() = 0;
/// This function is called to tell the task to abort (check cbThreadPool::AbortAllTasks)
void Abort();
/// Override this function with the task's job
/// Return value doesn't matter
virtual int Execute() = 0;
So, it is good to preserve the "virtual" before the int Execute() in the derived class. (Although it is not necessary)