VECTOR - c.v[i]=b.v[i]*a; return c; } istream&...

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

View Full Document Right Arrow Icon
X #include<iostream.h> #include<conio.h> # const size=3; class vector { int v[size]; public: vector(); vector (int *X); friend vector operator*(int a,vector b); friend vector operator*(vector b,int a); friend istream& operator>>(istream &din,vector b); friend ostream& operator<<(ostream &dout,vector b); f }; } vector::vector() { } vector::vector (int *X) { for(int i=0;i<size;i++) {v[i]=X[i]; } } vector operator*(int a,vector b) { vector c; for(int i=0;i<size;i++) c.v[i]=a*b.v[i]; return c; } vector operator*(vector b,int a) { vector c; for(int i=0;i<size;i++)
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: c.v[i]=b.v[i]*a; return c; } istream& operator>>(istream &din,vector b) { for(int i=0;i<size;i++) {din>>b.v[i]; cout<<" "; } return din; } ostream& operator<<(ostream &dout,vector b) { for(int i=0;i<size;i++) {dout<<b.v[i]; cout<<" "; } return dout; } int X[size]={1,2,3}; i void main() {int a,b,c; clrscr(); vector n=X; cin>>a>>b>>c; int w[3]={a,b,c}; vector m=w; cout<<m; vector r; cin>>r; cout<<r; vector p,q; p=2*m; q=n*2; cout<<endl; cout<<p; cout<<q; 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

VECTOR - c.v[i]=b.v[i]*a; return c; } istream&...

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