Side16
Side16

Reputation: 19

Templates / polymorphism

I'm trying to make use of polymorphism. Basically, there's a class-name missing in the middle of the code. As I'm not used to templates, could someone give me a clue? Thank you

#ifndef TEMPLATE_H``
#define TEMPLATE_H


using namespace std;
template <class T>
class Template
{
public:
      Template(int);
      virtual  ~Template();
      virtual  void push(T val);
      T pop;
      virtual  bool isFull();
      virtual  bool isEmpty();
      virtual  void  sizeOf(T val) ;
    protected:
    private:
    int top,size;
};

#endif // TEMPLATE_H

#ifndef STACK_H
#define STACK_H

/***LIFO***/

using namespace std;

template <class S>
class stack: public Template{ // HERE, it says it's missing an expected class 
-name before {
    public:
        stack();
        virtual ~stack();
    protected:
    private:

};

#endif // STACK_H

Upvotes: 1

Views: 56

Answers (1)

Miles Budnek
Miles Budnek

Reputation: 30494

stack should inherit from Template<S>, not Template.

Template is not a class. It is a class template. Template<int> would be a class, or Template<std::string>. You cannot inherit from a class template, only from a class (or struct).

Upvotes: 2

Related Questions