I have a class defined as
class A{
public :
A(const int arg){
x = arg;
}
const int x;
int arr[x][x];
};
but the compiler gives
error : invalid use of non-static data member 'A::x'|
but as I declare x as static const int x
error: array bound is not an integer constant before ']' token|
Any solutions to this.
EDIT : The question has been marked as duplicate of another, but that question is more of concept, it doesn't provide a solution to it. I know the difference but I don't know the solution to the problem except for vectors, which is also mentioned in one of the answers too.
And remove the duplicate flag, since this is different than the post this question is marked as duplicate of.
Thanks.