我在我的主类中有一个名为cell的嵌套类。 I 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 Cell(int row,...)' - >'Something :: Cell :: Cell(int row,...)'..不在'Something'中, Cell的构造函数是'Cell :: Cell'。在命名空间中,ust前缀为单个'Something ::' – Peter