I want to do some processing before calling the second constructor. For example:
class Foo {
Foo(){ displayWindow(); }
//This is possible
Foo(int bar) : Foo() { windowSize = bar; }
//But how do I do processing before calling the second constructor?
Foo(int bar, int baz) {
addLabel(baz); // prototype = void addLabel(int)
Foo(bar);
}
}
How would I accomplish this (without using initialization functions)?
EDIT: I updated the example. It now shows that the default constructor HAS to occur last. If it doesnt, displayWindow wont take into account any of the updated variables.
Like this:
(Note that delegating constructors is a feature supported only in C++11 onward.)