小工具知识网

当前位置: 首页 > 行业知识 > 【嵌入式学习】C++day03.18

行业知识

【嵌入式学习】C++day03.18

2026-12-03 08:44:43 来源:互联网转载

一、思维导图

二、练习

1、

#include using namespace std;class Animal{private:    string name;    string color;    int *age;public:    //无参构造函数    Animal() {}    //有参构造函数    Animal(string name,string color,int age):name(name),color(color),age(new int(age))    {}    //析构函数    ~Animal()    {        delete age;    }    //拷贝构造函数    Animal(const Animal &other):name(other.name),color(other.color),age(new int(*other.age))    {}    //拷贝赋值函数    Animal &operator=(const Animal &other)    {        name=other.name;        color=other.color;        age=new int(*other.age);        return *this;    }    void show()    {        cout 

上一篇:怎么对服务器进行施压?

下一篇:台服怎么转世界服务器?