Okay let me clear things up here. You can include a cpp file all you want. The reason why you don't is because it can make your project confusing for others to understand. Also no one suggested that you do so. Here is a very basic example here.
myheader.h
Code:
class MyClass {
public:
int GetValue(void) const;
private:
int value;
}
myclass.cpp
Code:
include "myheader.h"
int MyClass::GetValue(void) {
return this->value;
}
main.cpp
Code:
#include "myheader.h"
#include <iostream>
using namespace std;
int main(void) {
MyClass x;
cout << x.GetValue();
return 0;
}
Of course since MyClass::value is never initialized running this may end up breaking the program but now you know what alpha was talking about.
There is also something called forword referencing. It is like prototyping for classes.
Code:
class myarray;
class my2darray {
public:
myarray array;
};
class myarray {
public:
my2darray array;
};
This is a horrible example of why this could be necessary but just put this little bit of knowledge in the back of your brain for when you need it.