使用条件:
1.明确表示由一个对象初始化另一个对象
2当对象作为函数的实参传递给形参时
3当对象作为函数的返回值时
#include <iostream>
using namespace std;
class Person{
private:
int m_age;
public:
Person(int age):m_age(age){
cout<<"Constructor; age = "<<this->m_age<<endl;
}
Person(const Person &p){
this->m_age = p.m_age;
cout<<"Copy Construct; age = "<<this->m_age<<endl;}
};
int main()