what is a binary overloading
Answers were Sorted based on User's Feedback
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 |
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 |
What are the valid types of data that the main () can return in C/C++ language
what type of questions
What is difference between class and object with example?
What are the main differences between procedure oriented languages and object oriented languages?
9 Answers IBM, Infosys, Wipro,
Explain polymorphism? What r the types of polymorphism? pls give examples?
What are the advantanges of modularity
What is stream in oop?
What are the benefits of interface?
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?
What is oops and why we use oops?
What is the oops and benefits of oops programming?
What is function overloading and operator overloading?