title: CUDA C++: declare a vector with length
body: <p>I recently found this won't work in my global CUDA C++ code that I plan to compile and later to be called in Matlab: </p>
  
  <p>int M = 10; float V[M];
  or if I were to import M value from the matlab host code. </p>
  
  <p>But this works:
  float V[10];</p>
  
  <p>I was told there exists a function called new that I can use to avoid this problem, but I read online and am still quite confused how to use this new function, and it seems only to apply to host code, is that right? If so, it won't apply to my case then, since my host code is in matlab. Is this a way to get around this, so that I don't have to change vector lengths one by one? Thank you! </p>