all .cpp files in your project are compiled
so if you define everything in a .h file:
GeSHi (cpp):
class CMyClass
{
public:
CMyClass();
~CMyClass();
MyFunction();
}
Created by GeSHI 1.0.7.18
you can implement that in a .cpp:
GeSHi (cpp):
#include "CMyClass.h"
CMyClass::CMyClass()
{
}
CMyClass::~CMyClass()
{
}
void CMyClass::MyFunction()
{
cout << "Lol" << endl;
}
Created by GeSHI 1.0.7.18
and then, if you want to use your class:
GeSHi (cpp):
#include "CMyClass.h"
int main()
{
CMyClass foo;
foo.MyFunction();
}
Created by GeSHI 1.0.7.18
having the definition of a class in a header makes it usable in more than 1 .cpp file
if you get errors about redifinition you can add this your header:
GeSHi (cpp):
#ifndef CMYCLASS_H
#define CMYCLASS_H
//your class
#endif
Created by GeSHI 1.0.7.18