There is a strange thing. Let us examine it now!
#include <iostream>
using namespace std;
class A {
public:
A() : b(0), a(0){}
private:
int a;
int b;
};
int main () {
return 0;
}
![](http://hi.csdn.net/attachment/201111/11/0_13209990010s67.gif)
Warning! This is due to the mismatch between initializing sequence and the declare order. The right format should be like this:
#include <iostream>
using namespace std;
class A {
public:
A() : a(0), b(0){}
private:
int a;
int b;
};
int main () {
return 0;
}
or like this:
#include <iostream>
using namespace std;
class A {
public:
A() { b = 0; a = 0; }
private:
int a;
int b;
};
int main () {
return 0;
}
Please note that when initialized inside the function, it doesn't matter in terms of the mismatch sequence.