Actually, what you wrote is illegal in C++! In C++, you cannot make a VLA or variable length array on the stack. If n was considered constant, that would be legal but then n would no longer be of variable value. The correct way to do what you're doing is to make it dynamically via new or some allocator i.e. int ar = newint[n];
There is no real comparison to that. A vector is defined as an array of data that can be resized. The idea behind your array is that it cannot be resized thus is static.