C++类的六个特殊成员函数
1.设置六个函数的参数,先让函数运行起来 // // Created by liuhao on 20-1-1. // //================================================================================= #include <iostream> //using namespace std; class Stu { private: std::string name = "无名氏 "; int age = 0; int *d = nullptr; public: Stu() { std::cout << name << age << " 执行了无参构造函数!" << std::endl; }; Stu(int a) { std::cout << name << age << " 执行了有参构造函数!" << std::endl; }; Stu(const Stu &s) { std::cout << name << age << " 执行了拷贝构造函数!" << std::endl; }; Stu &operator=(const Stu &s) { std::cout << name << age << " 执行了拷贝赋值运算符函数!" << std::endl; }; Stu(Stu &&s) {