Created
December 14, 2012 01:12
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <whatev> | |
#include <summative.hpp> | |
int main() { //you can structure this however you want, just my personal onions | |
init(); | |
run(); | |
cleanup(); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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