#include <iostream.h>
class IntArray{
int *p, junk;
int size;
public:
IntArray(int size){
p = new int[size];
this->size = size;
}
int length(void)const{
return size;
}
void resize(int newsize){
int *temp = new int[newsize];
for(int i=0; i<newsize && i < size;i++){
temp[i]=p[i];
}
delete[] p;
p = temp;
size = newsize;
}
int &operator[](int ix){
if(ix>=size || ix < 0){
return junk;
}
else{
//return p[ix];
return *(p+ix);
}
}
~IntArray(void){
delete[] p;
}
};
int main(void){
IntArray a(5);
int i;
for(i=0;i<5;i++){
a[i] = i*2;
}
for(i=0;i<10;i++){
cout<<a[i]<<endl;
}
a.resize(10);
for(i=5;i<10;i++){
a[i] = i * 100;
}
for(i=0;i<10;i++){
cout<<a[i]<<endl;
}
return 0;
}