Define Functions out of Class template in C++ -
i've been faced error class stack' used without template parameters" > while trying make template stack class
template <class t> class stack{ /// declare new class named stack private : t* data; int pointer; int size1; public : t pop(); t top(); bool push(t); bool isfull(); bool isempty(); stack(int size1) { this->size1 = size1; pointer = 0; data = new int [size1]; } ~stack() { delete [] data; } };
the real problem want define functions outside of template class!!(for more readability) doesnt work!!
here's defenition 1 of functions :
template <class t> bool stack<t>::isfull() { if(pointer==size1+1) return true; return false; }
if function's definition steps class code block , works fine ...?!
this how call in main : stack operator(size) ;
have missed out <t>
1 of function definitions? i.e. have this:
template <class t> bool stack::isempty()
instead of this:
template <class t> bool stack<t>::isempty() ^^^
Comments
Post a Comment