Hello!
I'd like to have a two dimensional array as a member of a class, bu if
I did it in the following way:
class A {
const int n;
int a[n][n];
public:
A(int nn): n(nn) {};
~A() {};
};
this produce error, when I changed it to:
class A {
const int n;
int** a;
public:
A(int nn): n(nn) {
for (int i=0;i<n;i++)
a[i]=new int[n];
}
~A() {
for (int i=0;i<n;i++)
delete [] a[i];
}
};
it works fine, however when I tried to use it in some program like
this:
int main() {
int x,y;
A a(10);
return 0;
}
program compiled without any problems, but when I run it it was thrown
an unknown exception ... I don't understand what is going on.