Vector class

#include <iostream.h>
#include <conio.h>
class Vector
{
private :
int x[10];
public :
void readVector( )
{
cout<<”Enter 10 elements\n”;
for(int i =0; i<10;i++)
cin>>x[i];
}
void printVector( )
{
cout<<”The vector is :\n”;
for(int i =0; i<10;i++)
cout<<x[i]<<”\t”;
cout<<”\n”;
}
};
void main( )
{
Vector myVector;
myVector. readVector( );
myVector.printVector( );
}
Output :
Enter 10 elements
1
2
3
4
5
6
7
8
9
10
The Vector is :
1 2 3 4 5 6 7 8 9 10

0 comments: