C++ - 结构体构造函数使用总结 - _starsky - 博客园 (cnblogs.com)
结构体的构造函数创建及使用
//Definition for singly-linked list:
struct ListNode {
int val;
ListNode *next;
ListNode() : val(0), next(nullptr) {}
ListNode(int x) : val(x), next(nullptr) {}
ListNode(int x, ListNode *next) : val(x), next(next) {}
};