jeudi 19 mars 2015

c++ define a group of const struct in head file


I am using a C++ library which defines a struct.


Eg.



struct demo{
string x;
string y;
string z;
int n;
};


Normally I use this struct this way



demo s;
s.x = "AAA";
s.y = "BBB";


If I need to use certain values of the struct frequently. It makes sense to define a group of const struct in a new head file. What the right way to define the head file and implementation file(is it needed)? Further more, is there any convenient way to do this by #define preprocessor directives?



const struct AAABBB;
const struct AAACCC;
...
const struct BBBCCC;


in which x=AAA, y=BBB respectively.




Aucun commentaire:

Enregistrer un commentaire