I am having problems accessing the members of the base class in my derived class. Is there anything wrong with the way I defined my base class as in:
template <class T>
class Stack : private Llist<T>

Is there anything wrong with that?
I am getting errors from gcc in my derived class which says that members name and head_ptr are not declared in this scope. But they are public members in my base class, and using private inheritence they should be private members in my base class so they should be in scope right?

thank you for any help

Also this error, i have no idea what this means:
"there are no arguments to ‘remove_head’ that depend on a template parameter, so a declaration of ‘remove_head’ must be available"

template <class T>
class Llist
{
protected:
	Node<T> *head_ptr;
	Node<T> *tail_ptr;
	Node<T> *iterator;
	unsigned short count;
	void list_copy(Llist<T>& l);
	void list_clear();
	void find(Node<T>*& previous, Node<T>*& next, unsigned short pos);

public:
	Llist();
	Llist(Llist& l);
	~Llist();
	Llist<T>& operator=(Llist& l);    	
	void add_head(const T& t); 
	void insert(const T& t, unsigned short pos);
	void append(const T& t);
	short search( const T& t);
	void remove(unsigned short pos);
	void remove_head();
	unsigned short size();
	void start();	
	Iterator<T> startI();
	bool hasNext() const;
	T& getNext();
	T& operator[](unsigned short pos);
//	void print(ostream& o);	
	bool empty();

	//deleteme -- for debugging only
	string name;
	int newcnt;                     
};

template <class T> 
class Stack :  private Llist<T>
{
public:

	//For debugging only:
	Stack(){}
		{name = "Stack";}

	//Adds at top of stack.	
	void push(const T& t) 
		{add_head(t);}

	//Removes from top of stack.
	//Precondition: Stack must not be empty.
	void pop() 
		{remove_head();}

	//Returns reference to data element at top of stack.
	T& top() 
		{return head_ptr->data();}

	//Returns size of stack.
	//size()
	using Llist<T>::size;
	
	//Returns true if size =0.
	//empty()
	using Llist<T>::empty;

};

Where is Node defined?

In another file. It's included in Llist.h which is then included in Stack.h, so it should be available. Here is the declaration.
And my implementations are in my .h files following the headers. No separate .cpp files.

template <class T>
class Node
{
	T _data;
	Node<T> *_link;
public:
	Node();
	~Node();
	Node(const T& Data, Node<T> *Link=NULL);
	bool operator==(const Node<T>& n);
	T& data();
	Node<T>* link();
	void setLink(Node<T> *n);

};

Interesting problem. Below is a small sample of the problem and fix. Seems like you need to Llist<T>::. http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html

template <class T>
class Llist
{
public:
    Llist(){;}
    void remove_head()
    {
    }
private:
    T foo;
};

template <class T>
class Stack :  public Llist<T>
{
public:
    Stack(){}
    void pop()
    {
         //remove_head();
        Llist<T>::remove_head();
    }
};

int main()
{
    return 1;
}

thanks for the fix, it solved the problem. I wish I could understand that link but it's a little over my head. I understand some of it but then got lost...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.