Hello,
first of all if i tried to create a personal stack but compiler reports me these errors:
MyStack.cpp:8: error: template argument required for ‘class StackMio’
MyStack.cpp:8: error: expected template-name before ‘<’ token
The code is:
Where are the errors? It's the first time i create a template so..Code:#ifndef STACKMIO_H #define STACKMIO_H #include<list> template <class T> class StackMio : private list <T> { public: void push(const T& value) { push_front(value); } void pop(const T& value) { pop_front(value); } void print() { for(list<T>::iterator it=this->begin();it!=this->end();it++) cout<<*it; } }; #endif
Second question: Can I use iterators like in the "Print" function? I read that the iterators can't be used with queue, stacks etc...So how I could "slide" my Stack/Queue? Thanks





Reply With Quote