标准代码(正确代码)
#include <iostream>
#include <Windows.h>
//#include <string>
#include "Human.h"
using namespace std;
#define addr_len 64
//定义一个"人类"
class Human {
public:
Human();
Human(const Human &);
Human(int age, int salary, string name);
Human& operator=(const Human &other);
~Human();
void description() const;
string getName() const;
int getAge() const;
int getSalary();
void setAddr(char*addr);
private:
int age = 22;
int salary = 25000;
string name = "无名氏";
char *addr = "china";
};
Human::Human(const Human &other) {
name = other.name;
age = other.age;
salary = other.salary;
cout << "调用手动拷贝函数" << endl;
}
Human::~Human() {
delete addr;
}
string Human::getName() const {
return name;
}
int Human::getAge() const {
return age;
}
int Human::getSalary() {
return salary;
}
void Human::description() cons