鱼C论坛

 找回密码
 立即注册
查看: 6173|回复: 1

declaration of 'Superclass x' shadows a parameter是什么意思

[复制链接]
发表于 2013-1-19 10:13:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 压寨宝宝 于 2013-1-23 09:41 编辑
  1. class Superclass
  2. {
  3. public:
  4. Superclass(int);
  5. }

  6. class Subclass : public Superclass
  7. {
  8. public:
  9. Subclass(int);
  10. }
复制代码



按如上方式的基类和子类的带参数的构造函数。
如果按照一般的方式子类的构造函数应该是:


  1. Subclass::Subclass(int x): Superclass(x)
  2. { . . . }
复制代码


但是如果我这样做
  1. Subclass::Subclass(int x):
  2. {
  3.    Superclass::Superclass(x);
  4. }
复制代码



就会报出这样的错
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++。多多指教!~~~

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2013-1-22 19:22:33 | 显示全部楼层
各位大师帮帮忙啦!~~~~~这个不能沉,,谢谢!!~~~
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-25 00:15

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表