Multiple choice

While overloading an operator, the name of the method must be

  1. void

  2. virtual

  3. abstract

  4. operator

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

One of the features of C++ is that you can give special meanings to operators, when they are used with user-defined classes. This is called operator overloading. You can implement C++ operator overloads by providing special member-functions on your classes that follow a particular naming convention. For example: To overload the' +' operator for your class, you would provide a member-function named operator+ on your class, similarly to overload the operator '>', the name of the function will be operator>. While overloading an operator, the name of the method must be 'operator'.