我有以下内容:
int main()
{
struct A
{
unsigned char x, y;
A(unsigned char x, unsigned char y)
{
this.x = x; // Error: expression must have class type.
thix.y = y; // Error: expression must have class type.
}
};
return 0;
}
如何正确引用struct A
的x
和y
变量,而不是构造函数参数中A
的x
和y
变量?
谢谢。
this
指针始终存在。使用this->
或(*this).
来解引用它。 - πάντα ῥεῖC
有struct
,所以我以为这个问题会有点相关。抱歉。 - Hatefiend