Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write a short note on Overloading of Binary Operator?

Answers were Sorted based on User's Feedback



write a short note on Overloading of Binary Operator?..

Answer / rupinder

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 ?    9 Yes 4 No

write a short note on Overloading of Binary Operator?..

Answer / saranya

In overloading binary operators the object to the left of the operator is used to invoke the operator function while the operand to the right of the operator is always passed as an argument to the function.
eg) sum.x = x + real.x
here x is used to invoke the function +() and real.x is passed as argument to that function.

Is This Answer Correct ?    8 Yes 5 No

Post New Answer

More OOPS Interview Questions

How is class defined?

0 Answers  


What is the expansion of OOPS?

24 Answers   TCS,


Polymorphism with an example?

8 Answers   Accenture, emc2,


function overridind means and simple program

2 Answers  


How to hide the base class functionality in Inheritance?

0 Answers   Viscus Infotech,


WHAT'S THE OOPS BASIC OOPS CONCEPTS IN DOTNET

1 Answers  


what is a ststic variable and stiticfunction briefly explain with exmple and in which case we use

2 Answers   HCL,


What is for loop and its syntax?

0 Answers  


Explain polymorphism? What r the types of polymorphism? pls give examples?

4 Answers   HCL,


write a program to find the largest of two numbers without using for,while,switch,if else, conditional operator and do while using c++ pgmng language

3 Answers   Satyam,


why to use template classes in c++?

1 Answers  


WAP to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

1 Answers  


Categories