E7OPTROV - t.y=(x*c2.y)+(y*c2.x); return t; } void comp ::...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream.h> #include<conio.h> class comp { int x,y; public: void get() { cout<<"Enter the values"; cin>>x>>y; } void put() { cout<<"Values "<<x<<"+i"<<y; } comp operator+(comp); comp operator-(comp); comp operator*(comp); void operator/(comp); }; } comp comp :: operator+(comp c) { comp t; t.x=x+c.x; t.y=y+c.y; return t; } comp comp :: operator-(comp c) { comp t; t.x=x-c.x; t.y=y-c.y; return t; } comp comp :: operator*(comp c2) { comp t; t.x=(x*c2.x)-(y*c2.y);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t.y=(x*c2.y)+(y*c2.x); return t; } void comp :: operator/(comp c2) { float a,b; a=float((x*c2.x)+(y*c2.y))/((c2.x*c2.x)+(c2.y*c2.y)); b=float((y*c2.x)-(x*c2.y))/((c2.x*c2.x)+(c2.y*c2.y)); cout&lt;&lt;&quot;Values &quot;&lt;&lt;a&lt;&lt;&quot;+i&quot;&lt;&lt;b; } void main() { clrscr (); comp a1,a2,a3,a4,a5,a6; a1.get(); a2.get(); a3=a1+a2; a4=a1-a2; a5=a1*a2;r a1/a2; a1.put(); a2.put(); a3.put(); a4.put(); a5.put(); getch(); }...
View Full Document

This note was uploaded on 10/25/2010 for the course CMPN SEM1 taught by Professor Thakur during the Fall '06 term at University of Mumbai.

Page1 / 2

E7OPTROV - t.y=(x*c2.y)+(y*c2.x); return t; } void comp ::...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online