Overloading binary operators, C/C++ Programming

Overloading Binary Operators

class SI

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

public:

SI(){};

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

void putdata(void);

SI operator+(SI);

};

SI SI::operator+(SI i1)

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

}

void SI::putdata(void)

{cout<<"Principle is: "<

cout<<"Interest is "<

cout<<"Amount 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:18:17 AM | Location : United States







Related Discussions:- Overloading binary operators, Assignment Help, Ask Question on Overloading binary operators, Get Answer, Expert's Help, Overloading binary operators Discussions

Write discussion on Overloading binary operators
Your posts are moderated
Related Questions
Explain Formatted Input Output with File Pointer? Likewise there are equivalents to the functions scanf and printf which write or read data to files. These are called fscanf a

Charity Ball Organizer Many charities support good causes, but one of the difficulties each of them has is organizing their fundraising events. After nearly a semester of C progra

Question 1: (a) Explain clearly the following concepts using suitable examples of your own:- (i) concrete class v/s abstract class (ii) constructor v/s over

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

F u nction overloading: Functions can be defined with same name.  Depending upon the type of argument passed the function will perform.  This is known function overloading

Constructors and Destructors: A Class is defined as constructor by declaring a constructor in the form of function inside the class.  In other word a function in the name of


Explain Operators in C Language? The C language is very rich in built - in - operators and it places more significance on operators than do most other computer languages. The C

The task consists of two parts which are both preferably implemented in one source file. Towards the end of this document you will find a code skeleton that you must assume. Start