list source code

Feb 20, 2008 at 5:12pm
Does anyone know where I can find the 'list' source code.

By this, I mean 'push' and 'pop' and all that good stuff
Feb 20, 2008 at 9:27pm
You are talking about the STL std::list template class, right?

You can find the source in your compiler's include/C++/... directory. That said, you probably don't want to mess with STL source code directly. There is a lot of stuff in there that is way over the head of beginner- and intermediate-level programmers.

Better just to google around "linked list" and write your own version, with your own push and pop functions. You'll learn more that way.

The main trick is the template feature:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
template <typename DataType>
struct Node {
  DataType        data;
  Node<DataType> *next;
  };

template <typename DataType>
class List {
  private:
    Node<DataType> *head;
  public:
    ...
  };

Hope this helps.
Last edited on Feb 20, 2008 at 9:28pm
Topic archived. No new replies allowed.