#include<iostream>
using namespace std;

const int LIMIT = 10;
class Safearray { 
  private:    
    int arr[LIMIT];
  public:
    int& operator [ ](int n) 
    {
     if( n< 0 || n>=LIMIT ) { 
       cout << "\nIndex out:";
       exit(1); 
      }
     return arr[n];
    }
};
main()
{
     int j, x,temp; 
     Safearray sa1;
     for( j=0; j<LIMIT; j++) 
          sa1[ j ] = j*10;
     for(j=0; j<LIMIT; j++) {
          temp = sa1[ j ];
          cout << "Element " << j 
                  << " is " << temp<<endl ;
     }
     x = sa1[2]+ 3;
     cout<<"x = "<<x<<endl;
     system("pause"); 
 }
