#include <iostream>
usingnamespace std;
class My
{
public:
int a;
My()
{
this->a = 1;
}
};
int main()
{
My m1 = My(); // compiles, m1.a == 1
My m2; // compiles m2.a == 1
My m3(); // compiles, but I cannot access m3's field
return 0;
}
Can someone explain to me what is the difference beween m1 and m2's way of calling the default constructor and why m3 compiles but I cannot access its fields?