為什么我寫成 int getX(const Coordinate *this)就會報錯呢
VS2010中,我在Coordinate類中定義getX()函數(shù)時,
使用int getX() const; 就可以正常運行,
但是使用int getX(const Coordinate *this);的時候,編譯完報錯,并提示error C2143: 語法錯誤 : 缺少“)”(在“this”的前面)。
請問這個是怎么回事呢?
謝謝大家!
VS2010中,我在Coordinate類中定義getX()函數(shù)時,
使用int getX() const; 就可以正常運行,
但是使用int getX(const Coordinate *this);的時候,編譯完報錯,并提示error C2143: 語法錯誤 : 缺少“)”(在“this”的前面)。
請問這個是怎么回事呢?
謝謝大家!
2021-03-09
舉報
2021-03-18
this代表對象自己,不可做為傳參