Multiple choice technology programming languages

Which of the operators can be overloaded

  1. ::

  2. :?

  3. [ ]

  4. .

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

C++ allows overloading of most operators including the subscript operator [ ], function call operator ( ), arrow operator ->, and operators like new and delete. However, certain operators cannot be overloaded: scope resolution (::), member access (.), member access through pointer (.*), and conditional operator (?:).

AI explanation

In C++, the subscript operator [ ] can be overloaded, commonly used to give custom classes (like a matrix or smart-array wrapper) array-like element access syntax, e.g., obj[i]. The scope resolution operator (::) cannot be overloaded — it's a compile-time syntactic construct for resolving names, not a runtime operation on objects. The '.' (member access/dot) operator cannot be overloaded in standard C++ (unlike ->, which can be). ':?' isn't a real C++ operator at all (the conditional operator is '?:', which also cannot be overloaded), making it a distractor.