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 difference between inter class and abstract class...?

0 Answers  


Why do we use oop?

0 Answers  


Is this job good for future? can do this job post grduate student?

0 Answers  


How long to learn object oriented programming?

0 Answers  


There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.

0 Answers  






What is static modifier?

0 Answers  


what is the realstic modeling?

1 Answers  


why c++ is called OOPS? waht is inherutance? what is compiler?

5 Answers  


define oops with class and object

5 Answers   HCL, Tech Mahindra,


write knight tour problem which is present in datastructure

0 Answers  


what is the difference between class and structure in C++?

9 Answers   Aspire, IBS, TCS,


what is the difference between <stdio.h>and "stdio.h"?

5 Answers  


Categories