错误:初始化程序无法确定'K'的大小

smi*_*ile 5 c++

我得到了错误" intitializer fails to determine size of 'K'"

int K[]= new int[Vertices->total];
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

cod*_*ict 18

更改

int K[]= new int[Vertices->total]; 
Run Code Online (Sandbox Code Playgroud)

int *K = new int[Vertices->total];
Run Code Online (Sandbox Code Playgroud)

第一个是Java创建数组的方式,您K可以在其中引用整数数组.但是C++我们需要制作K一个指向整数类型的指针.