Rules of operator overloading, C/C++ Programming

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;



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;


Posted Date: 9/20/2012 8:16:49 AM | Location : United States

Related Discussions:- Rules of operator overloading, Assignment Help, Ask Question on Rules of operator overloading, Get Answer, Expert's Help, Rules of operator overloading Discussions

Write discussion on Rules of operator overloading
Your posts are moderated
Related Questions
Rahul is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with '

padovan string for natural numbers program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class Padov

A: No.       While realloc() need to copy the allocation, this uses a bitwise copy operation, that will tear several C++ objects to shreds. C++ objects must be allowed to copy t

C Program for CREATE MATRICES #include stdio.h> #include conio.h> void main() {           int a[10][10],rw=0,clm=0,i=0,j=0;           char s=' ';           c

Explain about Evaluation of Expression in c language? An Expressions are evaluated using an assignment statement of the form: variable = expression; The Variable is any v

How to Create A Data File? A data file should be created before it can be processed. A stream-oriented data file is able to be created in two ways. One is to create the file st

within 2 mins give me answer pllzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

Program is to define a class as student: Program is to define a class as student and display the records specific depending upon the number class student  {  private:

Project Description: I want an experienced programmer to program an RFID tag that will be read (maybe also written), and perform a call to a Filmmaker Pro 13 database. Skills