【发布时间】:2017-10-10 08:58:49
【问题描述】:
我的主类中有一个名为 cell 的嵌套类。 我c
class Something{
class Cell
{
public:
int get_row_Number();
void set_row_Number(int set);
char get_position_Letter();
static void set_position_Letter(char set);
void set_whohasit(char set);
char get_whohasit();
Cell(int row,char letter,char whohasit);
private:
char position_Letter;
int row_Number;
char whohasit;
};
};
我想在 .cpp 文件中实现嵌套类构造函数
Something::Cell Cell(int row,char letter,char whohasit){
Something::Cell::set_position_Letter(letter);
Something::Cell::set_row_Number(row);
Something::Cell::set_whohasit(whohasit);
}
但这是错误的。起初我认为正确的是Something::Cell::Something::Cell,但我也不认为这是真的。
【问题讨论】:
-
Something::Cell Cell(int row, ...)->Something::Cell::Cell(int row, ...).. 如果不在Something中,Cells 的构造函数将是Cell::Cell。在命名空间中,我们必须在所有这些前面加上一个Something::
标签: c++ inner-classes