Singly-linked list/Element definition: Difference between revisions
Content deleted Content added
→[[C]]: Corrected C example (C needs the struct tag, or alternatively a typedef; also a semicolon was missing; added C++ |
m →[[C plus plus|C++]]: missing semicolon in C++ code and typo in text |
||
Line 37:
int data;
link(int a_data, link* a_next = 0): next(a_next), data(a_data) {}
};
With this constructor, new nodes can be initialized directly at allocation; e.g. the
link* small_primes = new link(2, new link(3, new link(5, new link(7))));
|