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

Array of objects, Array of Objects: The objects can be declared just li...

Array of Objects: The objects can be declared just like a structure or even a primary data type.  Array of objects may be required to work with large set of data.   When the da

Oops, write a c++ program to find the prime numbers

write a c++ program to find the prime numbers

Define types of storage classes in c language, Define Types of storage clas...

Define Types of storage classes in C language? There are four storage classes in C language: 1. Automatic storage class. 2. External storage class. 3. Register storage cla

Wap to print numbers from 1-50 which are divided by 7, WAP TO PRINT NUMBERS...

WAP TO PRINT NUMBERS FROM 1-50 WHICH ARE DIVIDED BY 7 void main () { int a; clrscr (); a=1; while (a { if (a%7==0) printf ("%d\n",a); a++; } ge

Non-maxima suppression, Use the program called harris-shell.c and add some ...

Use the program called harris-shell.c and add some code to find the corners in the image checkers.jpg. You should say that a pixel in the image is a corner if it passes the given t

Compiler designin liliting instruction, Ravi is a newbie to the programming...

Ravi is a newbie to the programming and while learning the programming language he came to know the following rules:

Define the arithmetic operators in c language, Define the Arithmetic Operat...

Define the Arithmetic Operators in c Language? There are five arithmetic operators in C and they are Operator             Purpose +                        Addition -

Program to input 2 date & produce a new date - c++ program, /*  THIS PROGRA...

/*  THIS PROGRAM IS TO ASK USER TO INPUT TWO DATE & PRODUCE A NEW DATE  */ #include #include struct date  {   int dd;   int yy;   int mm;  }; date add(date d1,date d2)    {

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