I am trying to use a standard exception class in c++ like:
#include <iostream>
#include <exception>
using namespace std;
int main(){
int a[6]={12,3,2,4,5,6};
int n=6;
try{
cout<<a[6]<<" ";
}
catch(std::exception & exc)
{
cout<<exc.what();
}
return 0;
}
But instead of showing me the error - "out of index" ,it throws a run time error, saying that the "variable a is uninitialized" ,why? I have declared it as an array and make initialization of it. Please give me some advise why it does so?