正在加载图片...
第7章继承与派生 例7.1(续一) CLocation: CLocation(int x, int y) CLocation:X=X;∥/可以写成this->X=x CLocation:y=y;∥可以写成this->y=y; void CLocation Move To(int x, int y) CLocation:X=x;∥可以写成this->x=x CLocation:y=y;∥可以写成this->y=y; int CLocation: Getxo 可通过域运算符(:)访问类中的 return x 成员x和y,与使用this指针有同样 作用 int CLocation Getyo return y;例7.1 (续一) CLocation::CLocation(int x, int y) { CLocation::x = x; // 可以写成 this->x = x; CLocation::y = y; // 可以写成 this->y = y; } void CLocation::MoveTo(int x, int y) { CLocation::x = x; // 可以写成 this->x = x; CLocation::y = y; // 可以写成 this->y = y; } int CLocation::Getx() { return x; } int CLocation::Gety() { return y; } 可通过域运算符(::)访问类中的 成员x和y,与使用this指针有同样 作用 第7章 继承与派生
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有