暗夜蔷薇魅不错,修仙路上,大城和香
#include <iostream> using namespace std; class test{ public: test(int d = 0):data(d){ cout << "c" << endl; } test(const test &t){ cout << "copy" << endl; data = t.data; } test& operator= (const test &t){ cout << "assign" << endl; if(this != &t){ data = t.data; } return *this; } ~test(){ cout << "f" << endl; } test* operator&(){ cout << "operator&" << endl; return this; } const test* operator&() const{ cout << "const operator&" << endl; return this; } private: int data; }; int main(){ test t;//构造函数 test t1 = t;//拷贝构造函数 test t2; t2 = t;//operator= test t3; test *pt3 = &t3;//operator& const test t4; const test *pt4 = &t4;//const operator& }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
如何在没有core文件的情况下用dmesg+addr2line定位段错误
用QT制作3D点云显示器——QtDataVisualization
网友评论