Overloading binary operators using friend function, C/C++ Programming

Overloading Binary Operators Using Friend Function

class SI

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

public:

SI(){};

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

void putdata(void);

friend SI operator+(SI,SI);

};

SI operator+(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:19:25 AM | Location : United States







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

Write discussion on Overloading binary operators using friend function
Your posts are moderated
Related Questions
program to find if a no . is prime or not

Consider text comprised of sentences and sentences comprised of words. Words in a sentence will be space delimited. Given a text and K strings, task is to find out the number valid

what is oops

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

You have to write a subroutine (assembly language code using NASM) for the following equation.

Program to calculate tax: float tax (float) ; int main() {                 float purchase, tax_amt, total;                 cout                 cin >> purchase

Write a program which incorporates a function named compute and which is used to calculate the area and circumference of a circle. Use the main function for inputs and outputs.

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

1. Using Visual C++ and your OpenGL configured environment, write an application that displays a “unique” graphical scene that you designed and coded for this course. What yo

Why should I employ new instead of truthful old malloc()? A: Constructors/destructors, type safety, overridability. Constructors/destructors: unlike malloc(sizeof(Fred)), new