Why is the Child pass-through constructor necessary in this code? I would think that it wouldn't be, but the compiler (gcc and VS2010) complains when I remove it. Is there an elegant workaround? It just seems pointless to have to insert this shim into child classes.
class Parent
{
public:
Parent(int i) { }
};
class Child : public Parent
{
public:
Child(int i) : Parent(i) { }
};
int main()
{
Child child(4);
return 0;
}
usingstatement, e.g.,using Parent::Parent;, but I wonder if the lack of constructor inheritance in general is also due to arbitrary historical reasons.using Parent::Parent;), but your idea was rejected (but I don't have a quote).