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

Assignment Help:

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;

}


Related Discussions:- Overloading binary operators using friend function

C program for removing specified charecter , #include stdio.h> #include ...

#include stdio.h> #include conio.h> #include string.h>   void del(char[],char *); main() {           char str[30],ch,*pp;           clrscr();           p

Describe about the container class, Describe about the container class. ...

Describe about the container class. -Class to hold objects in external storage or memory. It acts as a generic holder. - It has a predefined behaviour and a known interface.

C program for sorting, C Program for SORTING # include stdio.h> void...

C Program for SORTING # include stdio.h> void main() {           char a;           int *p;           int i,j,temp;           clrscr();           p=&i;

Skilled programmer is required to build a standalone module, A skilled prog...

A skilled programmer is required to build a standalone module to extract, parse and store in database tables, word count data from web pages and RSS feeds. The module can take R

Develop a .net wrapper for a c++ dll, Develop a .NET wrapper for a C++ Dll ...

Develop a .NET wrapper for a C++ Dll Project Description: We have a classic VC++ Dll that requires a .NET wrapper built by you. Use latest Visual Studio and .Net framework sh

Explain zero based addressing, Explain zero based addressing. - Array s...

Explain zero based addressing. - Array subscripts always start at zero. - These subscript values are used to identify elements in the array. - As subscripts start at 0, a

Explain manipulators, Manipulators There are several classes in the ios...

Manipulators There are several classes in the iostream.h header file. One of them is ios class. This class stores the format state. For example, some bits explain the base in w

There are ''''n'''' ants on a ''''n+1'''' leng n, There are ''''n'''' ants ...

There are ''''n'''' ants on a ''''n+1'''' length rod. The ants are numbered from 1 to n and are initially placed at positions starting from position 1 till position n. They are mov

Defines the entry point for the console application, Defines the entry poin...

Defines the entry point for the console application. // #include "stdafx.h" #include #include #include"conio.h" using namespace std; double Determinant(double a[][3],int forde

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd