e3=e1.add(e2);
Seeing this statement and knowing that all applies to the class
ex
, the function prototype must be
ex add(const ex& e1) const;
and the corresponding implementation is
ex ex::add(const ex& e1) const
{
ex result;
result.a = this->a + e1.a;
result.b = this->b + e1.b;
return result;
}
or shorter using the constructor (and to be placed in the class definition)
ex add(const ex& e1) const
{
return ex(this->a + e1.a, this->b + e1.b);
}