First we create a simple C++ project.
mkdir example-project cd example-project
mkdir include
mkdir src
You can also use different directory structure. You just have to be consistent.
Create a C++ Headerfile include/my-class.h
namespace MyNamespace { class MyClass { public: int myVar; int myFunction() const; }; }
Create a C++ Sourcefile include/my-class.cpp
#include <my-class.h> namespace MyNamespace { int MyClass::myFunction(int x) const { char letter = '4' + std::string("2"); return myVar - x + 42; } }