hello everybody.
I'd like some suggestions on object creation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
class Styles{
int id;
int right_margin;
string name;
//etc
Style(int, int, string);
};
class Texts{
string text;
//etc
Texts(string, Style)
};
int main(){
Style style0(0, 4, "style_zero");
Style style1(1, 10, "style_one");
Style style2(2, 2, "style_two");
Texts text("Hello!", style1);
return 0;
}
|
well, i want to have some dozens of different Styles to be chosen from, everytime i create a new text. but everytime i use the program, only one of them will be picked up. so all the others will be useless, as will the chosen style after the Text construction has ended. yet all these style objects consume memory...
so my question is: what would be the better approach to solve this? this is what i could think...
1) create all the objects anyway, regardless of memory consumption (which I'm trying to avoid)
2) create all "objects" as macros (is that even possible?) so they will not really exist in memory. then i just put the macro i want in the text creation.
3) keep all the possible styles in an external text file, to be readen only when necessary. i like this, but not the idea of people being able to edit the files.
does databases fit here? i have absolutely no experience with it, so i do not know if it's a good offline option.
anyway, i'd like to know if there are any alternatives. thanks in advance!