Hi,
I recently came across a problem in my C++ adventures. I was making a function class that happened to use classes. It also needed to be flexible for any variable type. So without hesitance, I used a template. Happily, I continued the program, until I began to declare the list. Here was my code:
As we can see, this snippet has some problems, and a question arises because of that problem. How can I use a template with the list class? So that list will work for any variable type.
Also, the compiler keeps complaining this:
Line 24 refers to:
Any help?
Thanks,
Austen
I recently came across a problem in my C++ adventures. I was making a function class that happened to use classes. It also needed to be flexible for any variable type. So without hesitance, I used a template. Happily, I continued the program, until I began to declare the list. Here was my code:
Code:
template <class T>
class Stack {
public:
virtual void push(T c) = 0;
virtual char pop() = 0;
};
template <class T>
class List_Stack : public Stack {
private:
list <T> lc;
};
Also, the compiler keeps complaining this:
Code:
24 program.cpp expected class-name before '{' token
Code:
class List_Stack : public Stack {
Thanks,
Austen
Comment