66 views
#include <iostream>
using namespace std;
#include <process.h>
const int LIMIT = 100;
class safearray{
int arr[LIMIT];
public:
int& operator [](int n){
if(n<0 || n>= LIMIT){
cout<<"\nIndex out of bounds: ";
exit(1);
}
return arr[n];
}
};
int main(){
safearray sa1;
int j;
for(j=0;j<LIMIT;j++){
sa1[j] = j*10;
}
for(j=0;j<LIMIT;j++){
int t=sa1[j];
cout<<"Element " << j << "is" <<t<<endl;
}
return 0;
}