Skip to content

Instantly share code, notes, and snippets.

@pmelanson
Created December 14, 2012 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmelanson/4281680 to your computer and use it in GitHub Desktop.
Save pmelanson/4281680 to your computer and use it in GitHub Desktop.
how you should structure your program and stuff you can structure the files something like summative.cbp src (short for source) main.cpp class.cpp include (headers) summative.hpp class.hpp
#ifndef CLASS_HPP
#define CLASS_HPP //in codeblocks you can just type "guard" then press ctrl-j
#include <whatever>
//if you need another class that you've made, declare it like this
class ineeddis;
class bum {
private:
int secret;
ineeddis yes;
public:
int return_secret() const; //if you define something like int foo() const that says that function will not modify anything, you don't really need it but whatever
bum_c(); //constructor
~bum_c(); //deconstructor
};
#endif
#include <bum.hpp> //for the declaration of class_c
#include <ineeddis.hpp> //you didn't say what was in the class ineedis in class.hpp, so do it here
int bum_c::return_secret() {
return secret;
}
bum_c::bum_c() : secret(1337) {
//construct stuff here
}
bum_c::~bum_c() {
//deconstruct, like delete pointers
}
#include <whatev>
#include <summative.hpp>
int main() { //you can structure this however you want, just my personal onions
init();
run();
cleanup();
return 0;
}
#include <bum.hpp>
#include <other classes that you make>
//btw .h and .hpp are both header files, doesn't matter which extension you use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment