You are confusing member variables with variables declared inside a member function.
class Foo {
public:
int arr[13][64][64][64]; //Will be allocated in the same memory as the instance
void func() {
int arr2[13][64][64][64]; //Will always be allocated on the stack
};
};
So if you have Foo* foo = new Foo()
arr
is allocated on the heap because the whole foo
object is allocated on the heap. On the other hand Foo bar();
now arr
is allocated on the stack because bar
is allocated on the stack.
Calling either foo->func()
or bar.func()
will allocated the arr1
array on the stack.