#include<iostream>usingnamespace std;//拷贝构造函数调用时机//1、使用一个已经创建完毕的对象来初始化一个新对象//2、值传递的方式给函数参数传值//3、值方式返回局部对象classPerson{public:Person(){
cout<<"Person默认构造函数调用"<<endl;}Person(int age){
cout<<"Person有参构造函数调用"<<endl;
m_Age=age;}Person(const Person &p){
cout<<"Person拷贝构造函数调用"<<endl;
m_Age=p.m_Age;}~Person(){
cout<<"Person析构函数调用"<<endl;}int m_Age;};//1、使用一个已经创建完毕的对象来初始化一个新对象voidtest01(){
Person p1(20);
Person p2(p1);
cout<<"p2的年龄为:"<<p2.m_Age<<endl;}//2、值传递的方式给函数参数传值voiddowork(Person p){}voidtest02(){
Person p;dowork(p);}//3、值方式返回局部对象
Person dowork02(){
Person p3;return p3;}voidtest03(){
Person p=dowork02();}intmain(){test01();test02();test03();return0;}
拷贝构造函数的定义与调用:
在 Person 类中定义了拷贝构造函数 Person(const Person &p),用于对象的拷贝初始化。
在代码中使用了已有对象初始化新对象的方式来触发拷贝构造函数的调用,即 Person p2(p1);。
一、函數進階復習 1、行轉列 select 用水儿量(噸) 统计项,
sum(case when t_account.month01 then USENUM end) 一月,
sum(case when t_account.month02 then USENUM end) 二月,
sum(case when t_account.month03 then USENUM end) 三月,
sum(case when …
本文首发于公众号:机器感知
https://mp.weixin.qq.com/s/KiyNfwYWU-wBiCO-hE9qkA
苏 The devil is in the object boundary: towards annotation-free instance segmentation using Foundation Models Foundation models, pre-trained on a large amount of data…