c++拷贝函数的调用 一调用就报错 然后之前正确的代码也运行不了了 照着b站视频编写的 不知道哪里错了 一个字一个字对着敲的
代码如下:
```c++
#include<iostream>
using namespace std;
class person {
public:
person() {
cout << "无参构造函数!" << endl;
}
person(int age) {
m_age = age;
cout << "有参构造函数!" << endl;
}
person(const person& p) {
m_age = p.m_age;
cout << "拷贝构造函数!" << endl;
}
~person() {
cout << "析构函数!" << endl;
}
int m_age;
};
void test01() {
person p1(20);
person p2(p1);
}
int main() {
test01();
system("pause");
return 0;
}
```