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

Overloading Binary Operators Using Friend Function

class SI

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



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

Explain the  bit fields portable or not? - No, Bit fields aren't portable. - As Bit fields can't span machine words and number of bits in a machine word is different on diff

write aprogram for random -search to implement if a[i]=x;then terminate other wise continue the search by picking new randon inex into a

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Project Description: Currently seeking someone who can create me a software application (google chrome crx file_ that will auto add all shoe sizes to cart directly and if not av

Write a recursive function recursiveMin that takes an integer array, a starting subscript and an ending subscript as arguments, and returns the smallest element in the array. The

Program of file data: FileData::FileData( ffblk& blk ) :     fileName( blk.ff_name ),     fileDate( (blk.ff_fdate >> 5) & 0x000F,               blk.ff_fdate & 0x0001F

The Special Pointer 'this' When various instances of a class come into existence, it naturally follows that each instance has its own copy of member variables. If this were not

How to write a global inline function First, let's get away from member functions for a moment and consider a global function.  To make a request that this function be in line:

This problem familiarizes you with using random numbers in C++. The program is to compute a good approximation of π using a simulation method called "Monte Carlo". The following fi