I'm writing this class constructor:
element(int f=0, int a)
{
first = f;
inc = a;
current = first - inc;
}
The parameters are assigned to member variables in the body of the constructor. I've been asked to get the following calls in main() to work:
prog = new element(3,5);
prog = new element(5);
I cannot change the order of (3,5). As in within the constructor, f needs to be passed first, and a second. However, f needs to be initialized to 0 if no value is passed in, that way the second call keeps f at 0 and instead only initializes a to 5.
The issue with this is that I get an error if I place the parameters in this order within the constructor signature.
How do I solve this?