#include
#include
using namespace std;
class Array{
public:
Array(){length=0;num=NULL;};
Array(int );
int &operator[](int );
const int &operator [](int ) const;
int getlength() const {return length;};
private:
int length;
int *num;
};
Array::Array(int n) {
try{
num=new int [n];
}
catch(bad_alloc)
{
cerr<<"allocate storage failure"<length)
throw string("out of bounds");
return num[i];
}
const int &Array::operator[](int i) const {
if (i<0 || i>length)
throw string("out of bounds");
return num[i];
}
int main(){
Array A(5);
int i ;
try{
for (i=0;i