Which of the operators can be overloaded
-
::
-
:?
-
[ ]
-
.
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 (?:).
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.