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
Question 1: (a) Describe the following objects and condition states: (i) ifstream and ofstream objects (ii) eof(), fail(), bad() and good() functions. (b) Write a C++ pr

to design a car that travels along the room and gives the length of the room

Pointer to function: int mul(int a, int b, int c) {   return a*b*c; } void main() {   int (*function_pointer)(int, int, int);   function_pointer = &mul;

Make a list of functions that are standard in C++. You must include each of the following for each function: Name of function Its parameters Data type it returns

Implement multiple stacks in a single dimensional array using c.

Difference between Echo and print statement. print()and echo() are language constructs in PHP, both are used to output strings. Both statements are of almost same Speed. ech


for object, malloc allocates memory in heap however doesn't invoke object's constructor to initialize the object. new allocates memory & also invokes constructor to initialize the

Hello. I need a solution for this assignment. It is for C++ Language: Create a BusinessPartner class that contains a first name, company name, and a telephone number. Create a Con