VECTOR - { vector c; for(int i=0;isize;i++)...

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> # 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() { for(int i=0;i±size;i++) {v[i]=0;} } 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)
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: { vector c; for(int i=0;isize;i++) c.v[i]=b.v[i]*a; return c; } istream& operator>>(istream &din,vector b) { for(int i=0;isize;i++) {din>>b.v[i]; } return din; } ostream& operator(ostream &dout,vector b) { doutb.v[0]; for(int i=1;isize;i++) {doutb.v[i];} return dout; } int X[size]={1,2,3}; i void main() { clrscr(); vector m; vector n=X; cin>>m; cout<<m; 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 - { vector c; for(int i=0;isize;i++)...

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