Struggling to override a couple operators in c++. The overall logic and math im
ID: 3718474 • Letter: S
Question
Struggling to override a couple operators in c++. The overall logic and math im not understanding. When writing a method to overload the % operator.If I’m comparing two integers and returning the %(also an int)
Int operator% (const int& ) const { }
Struggling to override a couple operators in c++. The overall logic and math im not understanding. When writing a method to overload the % operator.
If I’m comparing two integers and returning the %(also an int)
Int operator% (const int& ) const { }
If I’m comparing two integers and returning the %(also an int)
Int operator% (const int& ) const { }
Explanation / Answer
int operator% (const int& b) const
{
return this + b; // add b to the first variable
}