STL lists

Login to reply to this topic.
Fri, 2007-11-16 02:11
Joined: 2007-09-04
Forum posts: 6

Is anyone familiar with the STL (Standard Template Library) in C++?
I want to use the list class but I do not immediately see any examples of how to use it with anything more complex than an integer class.

For example, how would you impliment a node with two strings such as this:

#include <list> // list class-template definition

using namespace std; 

class Node
{
   CString string1;
   CString string2;
}



list<Node> MyList; 

I would I put nodes into this list?


Mon, 2007-11-19 15:50
Joined: 2004-11-29
Forum posts: 1142
Re: STL lists

something like this I assume?

MyList.append(Node(string1,string2));

though, you should declare the members of the node as public, and write a constructor for it also (but I think you will get a default constructor that fit the above)

  • Login to reply to this topic.