M
mimi
1.Instead of using macro, I would like to use static const variables
in such situations.
class Foo {
public:
static const int SOMEVALUEWITHFOO = 1;
}
int main()
{
Foo test;
return 0;
}
My first question is: Is using static const variables instead of macro
appreciated?
2. How to define a global variable which is initialized by the
parameter of main, and gurantee its constness by technology?
Take the program in question 1 for example.If I want SOMEVALUEWITHFOO
to be initialized by the parameters of main, and its value should
never be changed, and every object of Foo has the same value of
SOMEVALUEWITHFOO, how should I design the program?
Thanks for any advice.
in such situations.
class Foo {
public:
static const int SOMEVALUEWITHFOO = 1;
}
int main()
{
Foo test;
return 0;
}
My first question is: Is using static const variables instead of macro
appreciated?
2. How to define a global variable which is initialized by the
parameter of main, and gurantee its constness by technology?
Take the program in question 1 for example.If I want SOMEVALUEWITHFOO
to be initialized by the parameters of main, and its value should
never be changed, and every object of Foo has the same value of
SOMEVALUEWITHFOO, how should I design the program?
Thanks for any advice.