Hello guys for another game I am working on I am trying to make a list of types of weapons that you can use and I was wondering how would you would go about this basically I am making pre-defined structs of weapons and armor. Here is the question should I just define them in a header file or should or extern them in the header and define them in the cpp file or is it a matter of taste?
heres some code if you are confused cause well I do that sometimes.
Now should I do thisCode:#ifndef weapon_h #define weapon_h #include <string> struct weapon { std::string name; //Weapon's name; int power; //How much it add's to your attack int retailPrice; //How much that it cost in a shop int sellingPrice; //How much you can sell it for bool isUpgradeable; //If is is allowed to be upgraded }; #endif//weapon_h
or define the sword into the cpp file and extern it in the headerCode:#ifndef weaponAttributes_h #define weaponAttributes_h #include "weapon.h" //name,power,retailPrice,selling price,is it upgradable weapon sword = {"sword",10,50,30,false}; #endif//weaponsAttributes_h



LinkBack URL
About LinkBacks


