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
Hello, Do you have any idea for programming project to simulate a network attack (threat) mechanism or a defense mechanism. Can I get some suggestions for this. Please include th

Can you help me with a C++ project?

write a program that calculates points along a rhodonea curve.... ? int fillArray( double data[ ], int nValues, double min, double max ); o Used to fill in the theta array. Return

The Shift Operators There are 2 shift operators : left shift ( >). These are binary operators. The format is                 operand >> number or operand   The first

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

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.   #include float start_poin

how can i make a program with !(not) operator

Receive 3 numbers and display them in ascending order from smallest to largest ed#

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

Inbuilt Functions i).  Functions to manipulate strings The cstring library defines many functions to perform some manipulation operations with C-styled functions. The followi