मराठी
महाराष्ट्र राज्य शिक्षण मंडळएचएससी विज्ञान (संगणक विज्ञान) इयत्ता १२ वी

Write any eight rules for operator overloading.

Advertisements
Advertisements

प्रश्न

Write any eight rules for operator overloading.

State any eight rules for operator overloading.

सविस्तर उत्तर
Advertisements

उत्तर

Eight rules for operator overloading are as follows:

  1. Only existing operators can be overloaded. New operators cannot be created.
  2. The overloaded operator must have at least one operand that is of a user-defined type.
  3. The basic meaning of an operator cannot change. i.e., we cannot redefine the plus (+) operator to subtract one value from another.
  4. The overloaded operators follow the syntax rules of the original operators.
  5. The following are some operators that cannot be overloaded:
    Size of operator
    • . Membership operator
    • * Pointer to member operator
    • :: Scope resolution operator
    • ?: Conditional operator
  6. Following certain operators cannot be overloaded using friend functions, but member functions can be used to overload them:
    • = Assignment operator
    • () Function call operator
    • [] Subscripting operator
    • → Class member access operator
  7. Unary operators, overloaded by means of a member function, take no explicit arguments and return no explicit values.
  8. Unary operators, overloaded by means of a friend function, take one reference argument.
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×