What is the syntax to overload an operator?

What is the syntax to overload an operator?
A. className::eek:perator<operatorSymbol>(parameters)
B. className:eek:perator<operatorSymbol>(parameters)
C. className.operator<operatorSymbol>(paramteres)
D. className->operator<operatorSymbol>(parameters)
 
Answer: a
Explanation: The class name is followed by the scope resolution operator. This is done to specify the class to which the function should belong to. Then the keyword operator should be used in order to indicate the operator that is to be overloaded. Then come the parameters list to specify other operands.
 

Tìm kiếm

Back
Top