c++day3(2023/12/28)

#include 
#include
#include
using namespace std;

class Person
{
    int *age;
    string &name;
public:
    void showPerson();
    Person(int age,string name):age(new int(age)),name(name)
    {
        cout << "Person有参构造调用了\n" << endl;
    }

    Person(const Person &other):age(new int(*(other.age))),name(other.name)
    {
        cout << "Person调用了拷贝构造函数" <

c++day3(2023/12/28)_第1张图片

你可能感兴趣的:(c++,开发语言)