I summarize the initialization places of various variables, would somebody check if it's correct?
1,2 or 3 cases will be explained later
__________________static_________const____________ _static const
integral____________2____________3________________ ___1 or 2
non-integral_______ 2____________3_____________________2
1. declaration place
Example:
Code:
class A{
public:
void foo();
static const int x=1;
A(){}
};
2. out of class
Example:
Code:
class A{
public:
void foo();
static const string s;
A(){}
};
const string A::s = "";
3. initialization list
Example:
Code:
class A{
public:
void foo();
const int x;
A():x(1){}
};