Image

Imagekritof wrote in Imagecpp

Template help?

Hi! I'm Kristen and I'm new to the community and the world of C++ programming.

I thought someone with more experience could help me with this. My assignment deals with using a class to create a stack (popping and pushing values). I want to define my class using a template so that I can declare different stacks with different data types. We were given a class definition and member function definitions today at school, but I can't seem to get it to work within a simple program. The error message I keep getting is: "'stack' : use of class template requires template argument list". I'd ask my teacher for help but I dont' think I'll have time since it's due next class on Thurday.

Can someone look at the code and tell me what's wrong?



/*I just included the class definition. if you see ] or [, it's supposed to be > or <. I had to switch it in order for everything to be seen in lj.*/

const int size=100;

template [class T] class stack
{
private:
T info [size];
int top_val;

public:
stack(); //default constructor
void push (T a);
T pop();
T top();
};