I am going through this question:Aggregates and pods
When an object of class in C++ with user defined default constructor, has only some of it’s data members initialized,will the rest of data members be value initialized?
Following is the program I tried resulting in compilation error:
#include <iostream>
using namespace std;
class A {
public:
A() {
i=10;
f = 10.0f;
c = 45;
d = 10.0;
}
void show() {
cout << i << "\t" << f << "\t" << c << "\t" << d<<"\n";
}
private:
int i;
float f;
char c;
double d;
};
int main() {
A a={20,20.0f};
a.show();
}
Your class does not qualify as an Aggregate because it has
privatenon-static data members.EDIT:
The rules are specified in:
C++11 8.5.4 List-initialization [dcl.init.list] Para 3:
Your program falls in none of the scenarios mentioned and hence falls under the the ill formed case.