Which operator can be overloaded using a friend (non-member) function?

2026

Which operator can be overloaded using a friend (non-member) function?

  1. A.

    ->

  2. B.

    =

  3. C.

    ()

  4. D.

    *

Attempted by 396 students.

Show answer & explanation

Correct answer: D

Concept. In C++ a small fixed set of operators can be overloaded only as member functions — they cannot be a non-member, and therefore cannot be a friend. These are the assignment =, subscript [], function-call (), and member-access ->. Every other overloadable operator — including the arithmetic operators — may be overloaded as a member or as a non-member function; that non-member form is commonly declared a friend so it can reach the class's private data.

Application. The question asks which of the four offered operators can be overloaded using a friend (non-member) function. Checking each against the rule:

Operator

Friend / non-member allowed?

=

No — must be a member function

()

No — must be a member function

->

No — must be a member function

*

Yes — can be a non-member friend

Why the restriction exists. For = and -> the language requires the overload to act on the left-hand object through an implicit this, and () and [] are likewise tied to a specific object, so the standard mandates a member function for all of them. An arithmetic operator such as * instead combines two operands symmetrically (e.g. a * b); a non-member friend operator* is both legal and idiomatic, and it lets either operand sit on the left.

Result. Among the choices, only the arithmetic operator * can be overloaded as a non-member friend function.

Explore the full course: Up Lt Grade Assistant Teacher 2025