Code should look like the following: // Headers ///////////////////////////////////////////////////////////////////////////// // Name: dir/Class.h // Purpose: What the class is for // Author: You // Modified by: You // Created: Wed Feb 28 21:41:10 2007 // Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions // Licence: // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program. If not, see . ///////////////////////////////////////////////////////////////////////////// #ifndef __HEADER__ #define __HEADER__ #ifdef SOME_DEFINE #define SOME_OTHER_DEFINE #endif #include #include #include "SomeBigClass.h" namespace Name { class SomeClass : class SomeBigClass { public: SomeClass(); SomeClass(int v); ~SomeClass(); bool setSomeVar(int s = 0); int getSomeVar(); private: void somePrivateMethod(); int someVar; unsigned* somePtr; QList someVector; }; } #endif // Source ///////////////////////////////////////////////////////////////////////////// // Name: dir/Class.cpp // Purpose: What the class is for // Author: You // Modified by: You // Created: Wed Feb 28 21:41:10 2007 // Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions // Licence: // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program. If not, see . ///////////////////////////////////////////////////////////////////////////// #include "Class.h" Name::SomeClass::SomeClass() { someVar = 3; somePtr = new unsigned[3]; someVector.clear(); } Name::SomeClass::someClass(int v) { someVar = 2 * v; switch (v) { case 0: if ((v == std::rand()) || (std::rand() < std::rand())) { somePtr = new unsigned[2 * v]; someVar = 16; } break; case 1: case 2: if (std::rand() == 23) somePtr = new unsigned[12]; if (std::rand() == 49) somePtr = new unsigned[14]; else somePtr = new unsigned[16]; break; default: somePtr = new unsigned[v]; break; } someVector.clear(); } Name::SomeClass::~SomeClass() { delete somePtr; } bool Name::SomeClass::setSomeVar(int s) { if (canChange) { someVar = s; return true; } return false; } int Name::SomeClass::getSomeVar() { return someVar; } void Name::SomeClass::somePrivateMethod() { for (int i = 0; i < someVar; ++i) someVar /= 2; }