Original Post
🔒 Locked
Super..... duper?
Advertisement
yep STL RULESSS!
because it generalises what a linked list does, you just have to specify what you want it to store
easy as
#include [list] //yep no .h
#define list[int] MYLIST //replace [] with angled brackets
//it keeps on removing them for some reason
MYLIST mlst1;
int x;
mlist.push_back(x);
//now your homework is to research iterators so you can
// access the links in the list
Edited by - CodeSpike on November 29, 2001 1:03:17 AM
Edited by - CodeSpike on November 29, 2001 1:04:48 AM
because it generalises what a linked list does, you just have to specify what you want it to store
easy as
#include [list] //yep no .h
#define list[int] MYLIST //replace [] with angled brackets
//it keeps on removing them for some reason
MYLIST mlst1;
int x;
mlist.push_back(x);
//now your homework is to research iterators so you can
// access the links in the list
Edited by - CodeSpike on November 29, 2001 1:03:17 AM
Edited by - CodeSpike on November 29, 2001 1:04:48 AM
quote:
Original post by Codespike
#define list[int] MYLIST
I usually recommend typedefs instead. But I guess they''re equivalent...
quote:
//replace [] with angled brackets
//it keeps on removing them for some reason
Use & lt; and & gt; (without the spaces and with the semicolons):
#include <list>
typedef std::list<int> IntegerList;
IntegerList mylist;
...
Start Here!
I would just use the STL, but if you are trying to learn how to write your own list, linked lists and other such things are usually taught in intro data structures classes and textbooks, so there are LOTS of examples available on the web, just do a search on google for data structures list code. Here is the first one I found (scroll down to LinkedList.cpp and LinkedList.h:
http://www.cs.fiu.edu/~weiss/dsaa_c++/Code/
http://www.cs.fiu.edu/~weiss/dsaa_c++/Code/
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement