A couple of points:
1) An include statement causes the contents of the specified file to be inserted at the spot of the include statement.
2) Before a name can be used in a file it has to be declared.
A .cpp file may start off with a definition like this:
Code:
void MyClass::someFunc()
{
....
}
The problem is neither the name MyClass nor someFunc has been declared in that file, which violates point 2). But if you include the header file for MyClass at the top of the file, it declares both the name MyClass and someFunc, and then you can use those names.
Since you presumably create some class objects in main(), if you do this:
MyClass a;
once again MyClass has to be declared before you can use that name. So, you need to include MyClass.h in main() as well.