Try to fix a clang missing assignment warning

This commit is contained in:
Milo Yip 2016-01-23 15:38:01 +08:00
parent d8c793f23f
commit a7490404ba

View File

@ -14,6 +14,12 @@ public:
Person(const Person& rhs) : name_(rhs.name_), age_(rhs.age_) {}
virtual ~Person();
Person& operator=(const Person& rhs) {
name_ = rhs.name_;
age_ = rhs.age_;
return *this;
}
protected:
template <typename Writer>
void Serialize(Writer& writer) const {
@ -107,6 +113,13 @@ public:
Employee(const Employee& rhs) : Person(rhs), dependents_(rhs.dependents_), married_(rhs.married_) {}
virtual ~Employee();
Employee& operator=(const Employee& rhs) {
static_cast<Person&>(*this) = rhs;
dependents_ = rhs.dependents_;
married_ = rhs.married_;
return *this;
}
void AddDependent(const Dependent& dependent) {
dependents_.push_back(dependent);
}