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...

what is a binary overloading

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is oops with example?

997


Is data hiding and abstraction same?

968


What is object in oops?

1022


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

4080


What is the difference between abstraction and polymorphism?

1048


Why do we use polymorphism?

1009


assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).

2072


What is encapsulation process?

1004


What is ambiguity in inheritance?

1052


What is the oops and benefits of oops programming?

926


What is the advantage of oop over procedural language?

1007


IS IT NECESSARY TO INITIALIZE VARIABLE? WHAT IF THE INSTANCE VARIABLE IS DECLARED final ? IS IT NECESSARY TO INITIALIZE THE final VARIABLE AT THE TIME OF THEIR DECLARATION?

2021


What is polymorphism what is it for and how is it used?

971


Which is not an object oriented programming language?

938


What is coupling in oop?

969