#include <iostream>
class Person {
private:
int age;
bool *p_sex;
public:
Person() : p_sex(new bool(true)) {
this->age = 18;
}
explicit Person(int age, bool p_sex) : age(age) {
this->p_sex = new bool(p_sex);
}
Person(Person &p) {
this->age = p.age;
this->p_sex = new bool(*p.p_sex);
}
Person &operator=(Person const &p) {
if (this != &p) {
this->age = p.age;
this->p_sex = new bool(*p.p_sex);
}
return *this;
}
~Person() {
delete (this->p_sex);
};
};
int main() {
return 0;
}
6.28作业
最新推荐文章于 2025-05-02 13:41:05 发布