|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 压寨宝宝 于 2013-1-23 09:41 编辑
- class Superclass
- {
- public:
- Superclass(int);
- }
- class Subclass : public Superclass
- {
- public:
- Subclass(int);
- }
复制代码
按如上方式的基类和子类的带参数的构造函数。
如果按照一般的方式子类的构造函数应该是:
- Subclass::Subclass(int x): Superclass(x)
- { . . . }
复制代码
但是如果我这样做
- Subclass::Subclass(int x):
- {
- Superclass::Superclass(x);
- }
复制代码
就会报出这样的错
error: no matching function for call to `Superclass::Superclass()‘
error: declaration of 'Superclass x' shadows a parameter
error: no matching function for call to `Subclass::Subclass ()‘
请教各位大神,declaration of 'Superclass x' shadows a parameter 是什么意思的?
这是为什么错了?谢谢,初学c++。多多指教!~~~
|
|