1 2 3 4 5 6
|
class aClass {
...
public:
aClass(); // constructor
aClassFun(double aParam); // public function
};
|
This class, with its public function, is declared in the header file aClassHeader.h
NO class instances are created here, not even as extern.
Then, at the top of the file module_1.cpp there is:
1 2 3
|
#include "aClassHeader.h"
class aClass myClass1; // as global
|
Here (in module_1.cpp) I use the public function of myClass1 and everything works fine!
Now, I *MUST* use the same aClass in module_2.cpp, hence at the top of this file I write:
1 2 3
|
#include "aClassHeader.h"
class aClass myClass2; // as global
|
Doing so I get linker errors:
/tmp/cce2gpMN.o: In function `aClass::aClassFun(double)':
module_2.cpp:(.text+0x1a0): multiple definition of `aClass::aClassFun(double)'
/tmp/cco6b7Gk.o:module_1.cpp:(.text+0x1a0): first defined here
I did google this error but I could not find similar conditions.
I would really appreciate some help. Thanks.