answersLogoWhite

0


Best Answer

Because the built in operator has the precision and compiler knows all the precision between the operators, and it works on that precision.

User can also create its own operator but the compiler does not come to know thow to make precision of this operator.

Therefore we dont use user defined operator

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can user defined operator overloading harm the readability of the program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is operator overloading?

I think you mean operation overlord??? It is the American, Canadian and British offensive on Europe in World War 2. They landed in Normandy on 6th June 1944 (Commonly called D-Day, Day of Days or Deliverance Day) and progressed throughout France liberating Paris on the 25th August. This allowed the allies a foothold in Europe.


What are used to document a program and improve its readability?

Comments


Why is it necessary to overload an operator?

The assignment is done explicit without internal operation. Subject to the programming language, explicit assignment operators are needed wherever implicit ones are insufficient. Implicit assignment is typically implemented as a flat copy, while explicit overloading of the assignment operator allows for any other suitable behavior. Consider this example in pseudocode similar to C++: class Demo { int* valuepointer; ... }; Demo a, b; ... b = a; Assigning a to b using implicit assignment means that a.valuepointer and b.valuepointer share the same value. Both a and b can change the pointed-to value, and the either will "see" the change. This is the required behavior in some cases, but often, you'd want to explicitly assign a to b such that each has its own pointer, accessing different copies of the value. This behavior would require an explicit assignment operator (or copy constructor).


Why scope resolution operator cannot be overloaded?

Generally the operators that can't be overloaded are like that because overloading them could and probably would cause serious program errors or it is syntactically not possible, For instance the sizeof operator returns the size of the object or type passed as an operand. It is evaluated by the compiler not at runtime so you can not overload it with your own runtime code. It is syntactically not possible to do. Even if it was pointer arithmetic relies on the correct value being returned by this operator since the compiler already knows how to calculate the correct value all overloading would do would be to allow you to calculate an incorrect value, something that would almost certainly lead to the program not working correctly. Scope resolution and member access operators work on names rather than values. C++ has no syntax for writing code that works on names rather than values so syntactically these operators can not be overridden. Again what useful purpose would overloading the conditional operator produce? I can think of none.


Write a simple program of operator overloading IN C SHARP?

class NumberString{private string _value;private static int getIntValue(string aString) {return int.Parse(aString);}public static NumberString operator +(NumberString n1, NumberString n2) {return new NumberString(getIntValue(n1._value) + getIntValue(n2._value));}public NumberString(int n) { _value = n.ToString(); }}

Related questions

What is operator overloading?

I think you mean operation overlord??? It is the American, Canadian and British offensive on Europe in World War 2. They landed in Normandy on 6th June 1944 (Commonly called D-Day, Day of Days or Deliverance Day) and progressed throughout France liberating Paris on the 25th August. This allowed the allies a foothold in Europe.


What are used to document a program and improve its readability?

Comments


Write java program for addition of two objects?

May be link might help -> http://www.allinterview.com/viewpost/408298.html There it is implemented through...... Operator Overloading!


difference between object and oriented program?

JAVA is an Object Based Programming Language. it doesn't provide multiple inheritance and operator overloading. while Object Oriented Lanuages provides both.


Are used to document a program and improve its readability?

Comments


Why is it necessary to overload an operator?

The assignment is done explicit without internal operation. Subject to the programming language, explicit assignment operators are needed wherever implicit ones are insufficient. Implicit assignment is typically implemented as a flat copy, while explicit overloading of the assignment operator allows for any other suitable behavior. Consider this example in pseudocode similar to C++: class Demo { int* valuepointer; ... }; Demo a, b; ... b = a; Assigning a to b using implicit assignment means that a.valuepointer and b.valuepointer share the same value. Both a and b can change the pointed-to value, and the either will "see" the change. This is the required behavior in some cases, but often, you'd want to explicitly assign a to b such that each has its own pointer, accessing different copies of the value. This behavior would require an explicit assignment operator (or copy constructor).


What are user-defined regions?

User-defined regions refer to specific sections within a program where the user can define custom behaviors or configurations. These regions allow users to group related code or settings together for easier management and understanding. They are typically used to improve code readability and organization.


How do operators provide the necessary data for Java program?

Technically, they don't. Operators only compare values and/or assign new ones. In the case of operator overloading for class objects, the specifics of how a particular operator interacts with class data is defined within the class method.


Why scope resolution operator cannot be overloaded?

Generally the operators that can't be overloaded are like that because overloading them could and probably would cause serious program errors or it is syntactically not possible, For instance the sizeof operator returns the size of the object or type passed as an operand. It is evaluated by the compiler not at runtime so you can not overload it with your own runtime code. It is syntactically not possible to do. Even if it was pointer arithmetic relies on the correct value being returned by this operator since the compiler already knows how to calculate the correct value all overloading would do would be to allow you to calculate an incorrect value, something that would almost certainly lead to the program not working correctly. Scope resolution and member access operators work on names rather than values. C++ has no syntax for writing code that works on names rather than values so syntactically these operators can not be overridden. Again what useful purpose would overloading the conditional operator produce? I can think of none.


Write a simple program of operator overloading IN C SHARP?

class NumberString{private string _value;private static int getIntValue(string aString) {return int.Parse(aString);}public static NumberString operator +(NumberString n1, NumberString n2) {return new NumberString(getIntValue(n1._value) + getIntValue(n2._value));}public NumberString(int n) { _value = n.ToString(); }}


C plus plus program using operator overloading?

class foo { private: int m_data; public: foo (int data=0): m_data (data) {} foo (const foo& source): m_data (source.m_data) {} foo (foo& source): m_data (std::move (source.m_data)) {} // operator overloads: assign foo& operator= (const int source) { m_data = source; return *this; } foo& operator= (const foo& source) { m_data = source.m_data; return *this; } foo& operator= (foo& source) { m_data = std::move (source.m_data); return this; } // compound operator overloads: increment and assign foo& operator+= (const foo& rhs) { m_data += rhs.m_data; return *this; } foo& operator+= (const int rhs) { m_data += rhs; return *this; } };


What is function of coupling?

coupling is a computer program, which is meant for the maintenance of the cohesion , coupling is inversely proportional to cohesion. When coupling and cohesion is combined then it acts as support to the high readability and maintainability of a computer program.