what is a binary overloading

Answers were Sorted based on User's Feedback



what is a binary overloading..

Answer / badmoon

Overloading binary operators (C++ only)

You overload a binary unary operator with either a nonstatic
member function that has one parameter, or a nonmember
function that has two parameters. Suppose a binary operator
@ is called with the statement t @ u, where t is an object
of type T, and u is an object of type U. A nonstatic member
function that overloads this operator would have the
following form:

return_type operator@(T)

A nonmember function that overloads the same operator would
have the following form:

return_type operator@(T, U)

An overloaded binary operator may return any type.

The following example overloads the * operator:

struct X {

// member binary operator
void operator*(int) { }
};

// non-member binary operator
void operator*(X, float) { }

int main() {
X x;
int y = 10;
float z = 10;

x * y;
x * z;
}

The call x * y is interpreted as x.operator*(y). The call x
* z is interpreted as operator*(x, z).

Is This Answer Correct ?    4 Yes 2 No

what is a binary overloading..

Answer / sandhya.v

When u overload a nonstatic member with single parameter
or nonmember with more than one parameter with the same
name ..

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More OOPS Interview Questions

What is the different between Applet and Application?

2 Answers  


suppose A is a base class and B is the derved class. Both have a method foo which is defined as a virtual method in the base class. You have a pointer of classs B and you typecast it to A. Now when you call pointer->foo, which method gets called? The next part of the question is, how does the compiler know which method to call?

3 Answers   EA Electronic Arts,


can we make a class static without using static keyword?

5 Answers   Aspire,


what is overloading and overriding?

7 Answers  


How can i write a code in c# to take a number from the user and then find all the prime numbers till the number entered by the user.

4 Answers   NIIT, TCS,






what is oppes

2 Answers  


What are the access specifiers avaible in c++?

4 Answers  


What is overloading in oop?

0 Answers  


what is the definition of incapsulation

2 Answers  


DIFFRENCE BETWEEN STRUCTURED PROGRAMING AND OBJCET ORIENTED PROGRAMING.

5 Answers  


How can you overcome the diamond problem in inheritance?

0 Answers   NIIT,


officer say me - i am offered to a smoking , then what can you say

0 Answers  


Categories