Skip to content

Commit

Permalink
Try to fix a clang missing assignment warning
Browse files Browse the repository at this point in the history
  • Loading branch information
miloyip committed Jan 23, 2016
1 parent d8c793f commit a749040
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions example/serialize/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class Person {
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 {
Expand Down Expand Up @@ -107,6 +113,13 @@ class Employee : public Person {
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);
}
Expand Down

0 comments on commit a749040

Please sign in to comment.