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
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

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

A: this is a procedure during exception handling while the destructor is called for all local objects in the stack among the place where the exception was thrown & where this is ca

get coding for padovan string

Question 1 Create a class String which stores a string value. Overload ++ operator which converts the characters of the string to uppercase (toupper() library function of "ctype.h

a palindrome is a string that reads the same from bhote the ends

What are the various types of control structures in programming? - Primarily there are 3 types of control structures in programming: Sequence, Selection and Repetition. - Se

Problem: (a) Describe a linked list. (b) Explain the three different types of linked list with the help of diagrams. (c) Give two advantages and two disadvantages o

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

how to make program c++