hello everybody. in the code below, what would be the lifetime of integer n?
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
usingnamespace std;
namespace Space{
int n = 10;
}
int main(){
cout << Space::n;
return 0;
}
if i create a namespace with lots of variables, to be used as reference values to lots of different functions, will it hit the memory usage by the program? are the variables 'alive' while the program is in execution?
in my specific case, i have a class name "Style" and about 20 objects from this class, each one holding different parameters (like font color, font size, background image, etc) that will be used by hundreds of other classes. so my idea is to make a namespace and put these 20 styles inside it, to serve as reference. or is there any better way of doing it?