Rules of operator overloading, C/C++ Programming

Assignment Help:

Rules of Operator Overloading

  • It is a function defined to an operator with new term or meaning.
  • It cannot produce new operator.
  • It cannot modified the meaning of the existing operator.
  • It can generate new functionality for the existing operators.
  • It helps to produce mathematical expression to replace arguments in function.
  • Binary and Unary operator overloading.
  • The following operators cannot be overloaded class member access (., .*), conditional (?:)sizeof, and scope (::).

Regular Function in a class

class SI

{float i,p,n,r,a;

public:

SI(){};

SI(int gp,int gn, int gr);

void putdata(void);

SI sum(SI, SI);

};

SI SI::sum(SI i1, SI i2)

{SI i3; i3.p=i1.p+i2.p; i3.i=i1.i+i2.i; i3.a=i1.a+i2.a; return i3;

}

void SI::putdata(void)

{cout<<"Principle is: "<

}

 

SI::SI(int gp,int gn, int gr){

p=gp;n=gn;r=gr; i=(p*n*r)/100; a=p+i;

}

int main()

{           SI i1,i2,i3;

i1=SI(1000,2,10); i1.putdata(); cout<

return 0;

}


Related Discussions:- Rules of operator overloading

Simplify the logical phrase with C++, hi i want wite a C++ program that get...

hi i want wite a C++ program that get one logical phrase (included {x,y,z,w,1,0}) and simplify it! but i ''m confused! thanxs for anubody help me...

Optimize and profile a c++ library for speed, Optimize and Profile a C++ li...

Optimize and Profile a C++ library for speed Project Description:  Optimize and Profile an existing C++ library for speed. This library uses OpenMP and OpenCV and C++ stan

Assignment, Design a black box suit for function whether a character or st...

Design a black box suit for function whether a character or string up to 25 characters

Bouncing Ball, Create an applet that bounces a blue ball inside an applet u...

Create an applet that bounces a blue ball inside an applet using Thread. The ball (diameter is 10) will start at position (0,0). When the ball hits the edge of the applet, the ba

Class, array of class objects and single inheritance

array of class objects and single inheritance

Illustrate the function definition, Illustrate the Function Definition? ...

Illustrate the Function Definition? The C code that explains what a function does is called the function definition. A function definition has the following form Type fun

Coding, how to make the coding

how to make the coding

Explain enumerated constants, Enumerated Constants Enumerated constants...

Enumerated Constants Enumerated constants enable the creation of new types and then explain variables of these types so that their values are restricted to a set of possible va

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd