First of all I'd like to apologize: my topic about virtual doesn't make any sense.
And now about the problem itself. Consider such an example:
//Unit1.cpp
#include "MyThread.h"
//Some Unit1 code
//Unit1.cpp
#include "MyThread.h"
//Some Unit1 code
To copy to clipboard, switch view to plain text mode
//Unit2.cpp
#include "MyThread.h"
//Some Unit2 code
//Unit2.cpp
#include "MyThread.h"
//Some Unit2 code
To copy to clipboard, switch view to plain text mode
Both of these files contain implementation of MyThread::run(). That causes no errors while compiling. But! When you try to link both [B]Unit1.o[/I] and Unit2.o you get the error saying about multiply declarations of MyThread::run(). The solution is to split MyThread.h into two files: MyThread.h, containing only the declaration, and MyThread.cpp, containing the implementation. This way you get MyThread::run() compiled once and you can safely link against MyThread.o
Bookmarks