Difficulty: Easy
Correct Answer: operator
Explanation:
Introduction / Context:
Operator overloading lets user-defined types work naturally with syntax like +, [], and <<. In C++, the mechanism is exposed by writing special function names that include a language keyword. This question asks you to identify that keyword exactly as it appears in code such as operator+ or operator[].
Given Data / Assumptions:
Concept / Approach:
The reserved word used to declare an operator overload is operator. You place the operator token after it to form the function name, for example operator== or operator*. The keyword friend can be used to grant access to a non-member overload, but it is not the keyword that makes the function an overload. The keyword override relates to virtual functions, not operators. There is no keyword named overload in C++.
Step-by-Step Solution:
Verification / Alternative check:
Attempting to declare overload void overload+(...) is illegal; compilers only recognize functions whose names begin with operator followed by a recognized operator token.
Why Other Options Are Wrong:
overload: not a C++ keyword.
friend: affects access, not naming of operator overloads.
override: applies to virtual functions to indicate overriding, unrelated to operator overloading per se.
Common Pitfalls:
Final Answer:
operator
Discussion & Comments