假设我有:
class A {
public:
A(int x_) : x(x_) {}
int x;
};
class B: public A { };
class C: public A { };
使用此代码,B 和 C 将没有任何构造函数(除了复制构造函数)。我想更改类中的某些内容A(不在Bor中C),以便两者B都C继承A. 这有可能吗?
假设我有:
class A {
public:
A(int x_) : x(x_) {}
int x;
};
class B: public A { };
class C: public A { };
使用此代码,B 和 C 将没有任何构造函数(除了复制构造函数)。我想更改类中的某些内容A(不在Bor中C),以便两者B都C继承A. 这有可能吗?