#include #include const int size=10; class vector { private: int *array; public: void *operator new(size_t size) { vector *myvector; myvector=::new vector; return myvector; } void operator delete(void *vec) { vector *myvector; myvector=(vector *)vec; delete(int *)myvector->array; :: delete vec; } void read() { for(int i=0;i<size;i++) { cout<<"vector["<<<"]"; cin>>array[i]; }
} int sum() { int sum; for(int i=0;i<size;i++) sum+=array[i]; } };
void main() { vector *myvector=new vector; clrscr(); cout<<"Enter vector data : "<<endl; myvector->read(); cout<<"sum of vector : "<<myvector->sum(); delete myvector; }