I just asked this question and the good answers mentioned using an initialization list. So I looked it up in many various places. It was often said that one can use an initialization list to select which constructor to use.
class First
{private:
int a, b, c;
public:
First(int x);
First(int x, int y);
}
First::First(int x, int y, int z = 0)
{ /* this is a constructor that will take two or three int arguements. */ }
First::First(int x, int y = 0, int z = 0)
{ /* and this will be called if one arguement is given */ }
I thought all assignments should be avoided, so how would I write the initializer lists for these two constructors?