构造函数/拷贝构造函数/赋值构造函数
来源:互联网 发布:c语言迷宫最短路径 编辑:程序博客网 时间:2024/06/10 13:46
#include <iostream>#include <vector>using namespace std;class A{public:A(){ cout << "默认" << endl; };A(int id) :m_id(id){ cout << "A::A() " <<m_id<< endl; };~A(){ cout << "A::~A() " <<m_id<< endl;};A(const A&rhs){m_id = rhs.m_id;cout << "A copy constructor" << endl; };A& operator = (const A&rhs){ m_id = rhs.m_id;cout << "A copy assignment" << endl; return *this;};private:int m_id;};void f(A a){return;}void g(A &a){return;}A h(A a){return a;}int main(){A aa(1);//f(aa);//g(aa);A bb = aa;bb = h(aa);return 0;}//程序运行结果//A::A() A aa; aa的构造函数//A copy constructor A bb == aa;//A copy constructor 参数传递,//A copy constructor 值传给临时变量//A::~A() 临时变量销毁//A copy assignment 赋值构造//A::~A() bb//A::~A() //A::~A() //请按任意键继续. . .
0 0
- 构造函数 拷贝函数 赋值构造函数
- 构造函数 拷贝函数 赋值构造函数
- 构造函数、拷贝构造函数、赋值函数
- 赋值函数、拷贝构造函数
- 拷贝构造函数赋值函数
- 拷贝构造函数,赋值函数
- 拷贝构造函数和赋值构造函数
- 拷贝构造函数与赋值构造函数
- 拷贝构造函数与赋值构造函数
- C++ 拷贝构造函数 赋值构造函数
- 拷贝构造函数与赋值构造函数
- 拷贝构造函数和赋值构造函数
- 拷贝构造函数 赋值构造函数
- 构造函数,拷贝构造函数,和赋值
- 赋值构造函数和拷贝构造函数
- 拷贝构造函数与赋值构造函数
- C++ 拷贝构造函数 赋值构造函数
- C++ 拷贝构造函数 赋值构造函数
- Oracle pl/sql编程 12---while循环
- Redis Java连接使用
- VBA运算符
- jQuery
- Redis学习笔记
- 构造函数/拷贝构造函数/赋值构造函数
- IOS笔记UI--侧滑效果的实现
- JAVA使用apache http组件发送POST请求
- Xmanager远程连接Linux服务器图形界面--DZY
- php异步http请求
- 基于jQury的UI框架 easyUI
- 手把手教你写Linux I2C设备驱动 tvp5158
- webview 模拟登陆
- easyUI 数据表格-datagrid