【发布时间】:2016-09-11 11:42:50
【问题描述】:
您好,我正在尝试创建一个程序,但遇到了一些麻烦我有 3 个名为 Goku vegeta Beerus 的类,其中 Goku 是基类,而 vegeta 和 Beerus 从 Goku 继承我想创建一个名为 rose 的 vegeta 对象和一个对象比鲁斯在悟空内部被称为上帝,但出现错误,任何人都可以指出我将如何做到这一点,感谢所有帮助,程序如下:
class Goku
{ public:
Goku();
˜ Goku();
string get_Name(void);
int get_power(void)
// This is what i want to do but keep getting errors
vegeta* rose;
Beerus* god;
};
class vegeta: public Goku
{
public:
vegeta(); //an intitializtion constructor
˜ vegeta();//destructor
string get_Name(void);
int get_power(void)
};
class Beerus: public Goku
{ public:
Beerus(); //an intitializtion constructor
˜ Beerus();//destructor
string get_Name(void);
int get_power(void)
};
注意我得到的错误是:vegeta cannot name a type 比鲁斯无法命名类型
【问题讨论】:
-
你试过“橡皮鸭调试”吗?当你打线
GokuBlack* rose;你知道GokuBlack是什么吗? -
哦抱歉 Gokublack 是个错误应该是 vegeta 我会马上编辑它谢谢你指出来
-
同样的问题也适用:当你炙手可热的
Beerus* god;,你知道Beerus是什么吗?
标签: c++ class derived-class base-class