正在加载图片...
2This指针 This指针是指向对象的指针,它隐含在类成员函数中,用来指向 成员函数所属类的正在被操作的对象。 编译器会把对象的地址赋给成员函数中的this指针。确保访问到的 数据成员属于这个对象 例如: DateDate(int y, int m, int d is -year=y, this - month this -> day =d 注:静态成员函数没有this指针2 This指针 This 指针是指向对象的指针,它隐含在类成员函数中,用来指向 成员函数所属类的正在被操作的对象。 编译器会把对象的地址赋给成员函数中的this指针。确保访问到的 数据成员属于这个对象 例如: Date::Date(int y,int m,int d) { this -> year = y; this -> month = m; this -> day = d; } 注:静态成员函数没有this 指针
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有