in Object Oriented Programming recategorized
0 votes
0 votes

Which of the following operators cannot be overloaded in $\textsf{C/C++}$ ?

  1. Bitwise right shift assignment
  2. Address of
  3. Indirection
  4. Structure reference
in Object Oriented Programming recategorized

3 Answers

2 votes
2 votes
Best answer

ans is option 4


Operators which cannot be overloaded[edit]

selected by
0 votes
0 votes
Option 4 is correct answer.
0 votes
0 votes

Most can be overloaded. The only C operators that can’t be are . and ?: (and sizeof, which is technically an operator). C++ adds a few of its own operators, most of which can be overloaded except :: and .*.

There is no fundamental reason to disallow the overloading of ?:. So far the committee just hasn’t seen the need to introduce the special case of overloading a ternary operator. Note that a function overloading would not be able to guarantee that only one of expr2 and expr3 was executed.

sizeof cannot be overloaded because built-in operations, such as incrementing a pointer into an array implicitly depends on it.

&,*,«,» can be overload so correct answer is 

Answer: D


Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true