Algo lab/linked lists
รุ่นแก้ไขเมื่อ 21:48, 9 กันยายน 2561 โดย Jittat (คุย | มีส่วนร่วม) (หน้าที่ถูกสร้างด้วย '== Array-based lists == == List nodes == === typedef === In C++, you can simply declare a new type based on known types using <tt>ty...')
Array-based lists
List nodes
typedef
In C++, you can simply declare a new type based on known types using typedef.
typedef int valueType;
valueType x = 10;
We will declare new valueType so that our linked list code works fairly well with any types. We will eventually use template to make generic linked list.
struct
struct ListNode
{
valueType val;
ListNode* next;
ListNode(valueType val, ListNode* next=0)
: val(val), next(next) {}
};