extern "C" { #include #include } class Array { protected: int* body; int last_index; public: Array(int k) { //constructor body = new int[k]; last_index = k-1; }//end constructor //destructor ~Array() { if (body) delete[] body; body=0; last_index=-1; } //subscript operator int& operator[] (int i) { if (i < 0 || i > last_index) // index is out of range exit(1); // exit or throw an appropriate // exception or take an appropriate action return body[i]; }//end subscript operator };//end class Array // function main ----------------------------------------------- int main() { Array x(4); x[0] = 1; printf("%d\n",x[0]); return 0; }//end main