The following piece of core works fine:
class A {
public:
int a;
int b;
};
A obj{ 1, 2 };
If, however, one adds default constructor explicitly: A(){}, one has to add another one for brace-enclosed initializer list, like:
A(int a, int b):a(a), b(b) {}.
Is there a shorter form like, e.g.:
A(const A& ab) { *this = ab } ???
The one above doesn't work.
A obj{ 1, 2 };work without writing out the fullA(int a, int b)constructor when a default constructor is explicitly present. - CompuChipclass A { public: int a = 1; int b = 2; };) and have all benefits of compiler-generated constructors? - Yksisarvinen