| 70 | }; |
| 71 | |
| 72 | class Dependent : public Person { |
| 73 | public: |
| 74 | Dependent(const std::string& name, unsigned age, Education* education = 0) : Person(name, age), education_(education) {} |
| 75 | Dependent(const Dependent& rhs) : Person(rhs), education_(0) { education_ = (rhs.education_ == 0) ? 0 : new Education(*rhs.education_); } |
| 76 | virtual ~Dependent(); |
| 77 | |
| 78 | Dependent& operator=(const Dependent& rhs) { |
| 79 | if (this == &rhs) |
| 80 | return *this; |
| 81 | delete education_; |
| 82 | education_ = (rhs.education_ == 0) ? 0 : new Education(*rhs.education_); |
| 83 | return *this; |
| 84 | } |
| 85 | |
| 86 | template <typename Writer> |
| 87 | void Serialize(Writer& writer) const { |
| 88 | writer.StartObject(); |
| 89 | |
| 90 | Person::Serialize(writer); |
| 91 | |
| 92 | writer.String("education"); |
| 93 | if (education_) |
| 94 | education_->Serialize(writer); |
| 95 | else |
| 96 | writer.Null(); |
| 97 | |
| 98 | writer.EndObject(); |
| 99 | } |
| 100 | |
| 101 | private: |
| 102 | |
| 103 | Education *education_; |
| 104 | }; |
| 105 | |
| 106 | Dependent::~Dependent() { |
| 107 | delete education_; |