Tuesday, February 20, 2018

c++ - derived assignment operator calling the one from a base



In the best rated answer to the question from this link, I don't understand how the derived assignment operator calls the assignment operator from the base class, i.e., this in this part of the code:



Derived& operator=(const Derived& d)
{
Base::operator=(d);

additional_ = d.additional_;
return *this;
}


what does



Base::operator=(d)



mean? What does it do? Cheers!


Answer



It's just a call to a member function on the current object. The current object inherited a function whose fully-qualified name is Base::operator=, and you can call it just like any other non-static member function.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...