I have searched for it and this seems to be the only way of calling a superclass constructor in C++:
class SuperClass
{
public:
SuperClass(int foo)
{
// do something with foo
}
};
class SubClass : public SuperClass
{
public:
SubClass(int foo, int bar)
: SuperClass(foo) // Call the superclass constructor in the subclass' initialization list.
{
// do something with bar
}
};
But I'd like to know, how can I call the superclass constructor in the constructor body instead of initialization list?
I have to process inputs of my child's constructor and pass complex processed parameters to superclass constructor, how do I achieve that?