Home How to link node objects in a data structure using templates?
Reply: 0

How to link node objects in a data structure using templates?

user846
1#
user846 Published in May 25, 2018, 8:59 am

I wanted to use templates to make more general data structures for example a stack by linking node* objects. But once I used the template the node class is no longer identified, the compiler says:

Error GCC template class Node’ declared here Error GCC invalid use of template-name ‘Node’ without an argument list

And there's my code on the header file so far:

#ifndef STACK_HPP
#define STACK_HPP
template <class Object>
class Node{
  friend class Stack;
  private:
    Object data;
    Node* next;
  public:
    Node(Object d);
    Node();
};
template <class Object>
class Stack{
  private:
    Node* top;
    int size;
    bool isEmpty();
  public:
    Stack();
    ~Stack();
    void Push(Object d);
    Object Pop();
    Object Spy();
};
#endif
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.343062 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO