📄 copy_ref.cc
字号:
#include <iostream>using namespace std;class A{ int data;public: A(){cout << "A()" << endl;} A(const A&ca){cout<<"A(const A&)" << endl;} ~A(){cout<<"~A()"<<endl;} void showAddress(){cout<<this<<endl;} A& getMyself(){return *this;} A getCopy(){return *this;}};int main(){ cout << "========1========" << endl; A a1; cout << "&a1=" << &a1 << endl; a1.showAddress(); cout << "========2========" << endl; A a2=a1; cout << "&a2=" << &a2 << endl; a2.showAddress(); cout << "========3========" << endl; a1.getMyself().showAddress(); cout << "========4========" << endl; a1.getCopy().showAddress(); cout << "========5========" << endl; A(); cout << "========6========" << endl; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -