VC++ error LNK2005 (class in extern. file)
the MS VC++ 2008 express edition compiler gives a strange linker error message:
Error 1 error LNK2005: "public: void __thiscall Class::function(int)" (?function@Class@@QAEXH@Z) already defined in class.obj main.obj
without any apparent reason. I wrote the following (simple) example to demonstrate the problem:
main.cpp:
Code:
#include "class.cpp"
int main()
{
Class someclass;
someclass.function(10);
}
class.cpp:
Code:
#include <iostream>
using namespace std;
class Class
{
public:
void function(int);
};
void Class::function(int number)
{
cout << "the number was: " << number << endl;
cin.get();
}
it compiles fine using dev-cpp 5.0.
sorry for my bad english...
Thanks