Not quite sure what you mean. Are x from A and x from B supposed to be the same thing? (Because they aren't.)
The equivalent of this Java snippet:
Code:
class Base
{
public Base(int arg1) {
}
}
class Derived extends Base
{
public Derived(int arg1, int arg2) {
super(arg1);
}
}
... is this C++ code:
Code:
class Base
{
public:
Base(int arg1) {
}
}
class Derived : public Base
{
public:
Derived(int arg1, int arg2)
: Base(arg1)
{
}
}
If you want to have easier refactoring (changing the base class) you can add a typedef for the base class at the start and call it super:
Code:
class Base
{
public:
Base(int arg1) {
}
}
class Derived : public Base
{
typedef Base super;
public:
Derived(int arg1, int arg2)
: super(arg1)
{
}
}