I've been having a problem with my gcc compiled program. The program itself is a text-based MUD server that I've been working on for a while. The problem comes at two points in the program where I use a template class Menu to create menus that the user can navigate. The linked list class has worked flawlessly on nontemplated classes throughout my program, except in this one instance. When I try to declare an iterator for a (custom) templated linked list class, the compile dies with the error:
'q' was not declared in this scope
Here's the partial linked list class definition
1 2 3 4 5 6 7 8 9 10 11 12 13
template <typename T>
class linklist
{
public:
struct node
{
T data;
node *link;
}*p;
...
};
Thanks a million, this has been giving me trouble for days. I'm still a bit new to template programming and I'm pretty confused as to when I need to include specific keywords for my templates. How did you know to use the typename keyword?