ferras alquasi,汕头除甲醛,北京奔驰戴克多少钱
// // main.cpp // this指针 // // created by mac on 2019/5/2. // copyright © 2019年 mac. all rights reserved. // 默认情况下,编译器为类的每个成员函数提供了一个隐式形参,该隐式形参成为this #include <iostream> using namespace std; class example{ private: int x; public: example(int a){ this->x=a; } void setvalue(int); void printaddressandvalue()const; }; void example::setvalue(int a){ this->x=a; } void example::printaddressandvalue()const{ cout<<"the object at address "<<this<<" has "<<"value "<<(*this).x<<endl; } int main(int argc, const char * argv[]) { // insert code here... example obj1(10),obj2(20); cout<<"address of objects are "<<&obj1<<" and "<<&obj2<<endl; obj1.printaddressandvalue(); obj2.printaddressandvalue(); return 0; }
address of objects are 0x7ffeefbff578 and 0x7ffeefbff570 the object at address 0x7ffeefbff578 has value 10 the object at address 0x7ffeefbff570 has value 20 program ended with exit code: 0
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
如何在没有core文件的情况下用dmesg+addr2line定位段错误
用QT制作3D点云显示器——QtDataVisualization
网友评论