c++声明结构体动态数组的问题

struct ListNode {
int val;
ListNode next;
ListNode(int x) : val(x), next(NULL) {}
};
然后我想达成的效果是
ListNode
p = new ListNodek;

就是说申请一个k(变量)维的数组,然后都初始化成0.
不改变结构体声明的情况下能做到吗?

 template<int N>
class ListNode<N>{
    int arr[N];
};
使用
ListNode<2> p = new ListNode<2>;

用C++模板理论上可以生成任意的程序,给你一本书,好好学吧。
https://download.csdn.net/download/yinxing408033943/4341621

https://www.zhihu.com/question/21656266

申明一个默认构造函数,初始化为0就可以了

大兄dei,很简单啦 构造的时候给x默认参数就好了呀

struct ListNode {
int val;
ListNode next;
ListNode(int x=0) : val(x), next(NULL) {}
};

比如:
int k=10;
ListNode *p = new LIstNode[k]