C++構造函數初始化列表中不能使用this指針

先看個例子:函數 class Point {//這個class用來表述「點」 public: Point(int x, int y) : this->x(x), this->y(y) { } void setX(int x) { this->x = x; } void setY(int y) { this->y = y; } public: int x; int y;
相關文章
相關標籤/搜索