我得到一个错误:请求成员“左上”在“第一”,这是一种非类型矩形

问题描述:

这里是我的代码:我得到一个错误:请求成员“左上”在“第一”,这是一种非类型矩形

class Coo 
{ 
    public: 
    int x, int y; 
}; 
class Rectangle 
{ 

    Coo *topLeft; 
    Coo *bottomeRight; 

} 
bool asf(Rectangle *first) 
{ 
    if(first.topLeft.x) /// Error in this line 

} 

你使用指针,所以你需要使用->而不是.,以取消引用指针。

if(first->topLeft->x)