【发布时间】:2017-05-04 02:08:28
【问题描述】:
这些是我的头文件类函数:
public:
hunter(string aSpecies); // create a hunter of the given species
void recordKills(string kill); // add a new kill to the end of the hunter's list of kills
string *theKills(); // return a pointer to the array of all kills by this hunter
int numberOfKills(); // how many kills have been recorded
和类变量:
private:
string kill;
int numberkilled;
string kills[20];
我不确定如何处理“字符串 *theKills()”
我尝试过这样做:
string hunter::*theKills(){
pointer = kills;
return pointer;
}
与 * 一样,它不会将 kills 识别为我的类变量的一部分,但我们应该使用相同的函数名称。
【问题讨论】:
-
不应该是
string* hunter::theKills(){吗?
标签: c++ class pointers inheritance