answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: X plus plus operator overloading in c sharp?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is plus operator is it unary or binary?

There is no unary plus in C, but if there were, it would have only one operand, unlike the binary plus which has two: x = a + b; /* binary plus */ x = + b; /* unary plus -- not in C*/ x = a - b; /* unary plus */ x = - b; /* unary minus */


What is operand in c plus plus?

An operand is the value that is being operated upon by an operator. For instance, the C++ increment operator (++) is a unary operator, which means it has only one operand, the variable that we wish to increment. This in the expression x++, x is the operand. The addition operator (+) is a binary operator and therefore has two operands. Thus in the expression x + y, x and y are the operands.


Write a c plus plus program to use plus operator to display the sum of 2 numbers and concatenation of two strings by using operator overloading?

There is no need to overload the plus operator to achieve this. It is already overloaded with this functionality. #include<iostream> #include<string> int main() { int x=40; int y=2; int z=x+y; std::cout<<x<<" + "<<y<<" = "<<z<<std::endl; std::string s1="Hello "; std::string s2="world!"; std::string s3=s1+s2; std::cout<<"""<<s1.c_str()<<"" + ""<<s2.c_str()<<"" = ""<<s3.c_str()<<"""<<std::endl; return(0); }


When to use the dot operator and when to use the arrow operator in c plus plus?

You use the dot operator when the left side is the name of the object or a reference to an object, and you use the arrow operator when the left side is a pointer to an object. Example: struct foobar x, *p= &x; x.field = p->field; (&x)->field = (*p).field;


Is x plus equals y is post increment or pre increment?

The '+=' operator behaves like a pre increment operator.


Can a make a signature on the sharp fx plus?

Yes, that would be F♯x (F triple sharp) - enharmonic with G sharp.


What represents the left hand side of a binary operator in c plus plus?

The left hand operand of a binary operator must represent a modifiable lvalue: void f (const int x, int y) { x = y; // error -- x is constant lvalue y = x; // ok }


What is the importance of overloading and overriding?

The only disadvantage of operator overloading is when it is used non-intuitively. All operators must behave with predictable results, thus it makes no sense to implement the plus (+) operator so that it behaves like a subtract (-) operator, or a multiply (*) operator, or indeed anything other than the intuitive sum of two objects.


What expression shows the value of the sum of x and 6?

The answer is x + 6. The plus sign (+) is used to indicate sums. A sum is the result of addition and + indicates the addition operator.


Why there is only 2 plus in c plus plus languagewhy not 3 or 4 plus?

I assume by 2 plus you really mean ++. This is the increment operator which is used to increment the operand. If placed before the operand, the operator evaluates the incremented operand (prefix increment). If placed after the operand, the operator evaluates the non-incremented operand (postfix increment). +++ and ++++ are meaningless but are assumed to mean incrementing an increment. If you wish to increment an increment, you must use the compound expression ++(++) or (++)++. Thus for the variable x, prefix incrementing twice would be achieved with ++(++x), while postfix incrementing twice would be achieved with (x++)++. You can also mix the two, such as ++(x++) or (++x)++, both of which would increment x twice but would evaluate the increment of x. If postfix increment is not a requirement, it would be much easier to use the compound expression x+=n, where n is the amount you wish to increment. This is the same as saying x=x+n.


Factor 6x2-11x plus 5?

Assuming that the first operator is 6x^2. The factors are (6x-5)*(x-1)


What is meant by an address operator in c plus plus?

The address-of operator is a unary operator which returns the address of its operand: int x = 42; // instantiate a variable of type int std::cout << "Value of x: " << x << std::endl; // e.g., 42 std::cout << "Address of x: " << &x << std::endl; int* p = &x; // store the address of x in a pointer variable std::cout << "Value of p: " << p << std::endl; // e.g., the address of x std::cout << "Address of p: " << &p << std::endl; std::cout << "Value referred to by p: " << *p << std::endl; // e.g., 42