Is there a way in c++ to combine a default parameter constructor with member initialization list?
So something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13
class Example{
private:
int var1;
string var2;
public:
Example(int a = 0, string b = ""): var1(a), var2(b)
{ }
};
The intention here is that if nothing is passed in, a and b are initialized to 0 and empty string, respectively. If, however, an int and string are passed in, then var1 and var2 will be set to their values via member initialization.