Optional arguments

This is my constructor:

Object(arg1 = default1, arg2 = default2, arg3 = default3)

Is there a way to initialize this with only specifying arg1 and arg3, and having arg2 stay as the default2?
I don't believe so, no.
BUT, you could make the object have if structures inside to sort out the data and maybe... just maybe... make it re-arrange them(sort of(hypothetically speaking)).
You'd have to change the order of parameters. The default parameter/s must always be the last one/s.
That would be a really good addition to C++0x to allow the call Object(10, default, -2);... I think
Thank you.
You could use constructor overloading for this.....but if you have all the three parameters with the same type then you could use templatization to solve the purpose
You could use constructor overloading for this.....but if you have all the three parameters with the same type then you could use templatization to solve the purpose
Topic archived. No new replies allowed.