You do not include one * .cpp inside another * .cpp. Instead of this:
myclass.h
class MyClass {
doSomething();
}
myclass.cpp
#include "myclass.h"
MyClass::doSomething() {
cout << "doing something";
}
run.cpp
#include "myclass.h"
etc..
Instead of including myclass.cpp inside main.cpp (so that the compiler sees both of them in one pass), you compile myclass.cpp and main.cpp separately, and then let the linker combine them into a single executable.
source
share