plz help!
-
Hi everybody. Can anybody help me please? :confused: Define a virtual class stack to define the stack popular operations • size() • push() • pop() • peak() • isEmpty() • isFull() Derive two classes from the virtual stack class, call the first class vectorStack and the second class listStack, use STL vector and list classes to implement the two derived classes. i tried this one but it's not working, do anybody have suggestions please /////////////////////////////////////// #include #include #include using namespace std; template class stack { private: public: virtual type size(); virtual void push( type e); virtual void pop( type & e ); virtual void peak(); virtual bool isEmpty(); virtual bool isFull(); }; template class vector ::public stack { public: void push(type v) { v.push_back(); } void pop(type v) { v.pop_back(); } bool isEmpty(type v) { return(v.empty()); } bool isFull(type vector) { vector.capacity(); } type size(type vec) { vec.size(); } }; template class list::public stack { public: void push(type v) { v.push_back(); } void pop(type v) { v.pop_back(); } bool isEmpty(type v) { return(v.empty()); } bool isFull(type vector) { vector.capacity(); } type size(type vec) { vec.size(); } }; void main() { stack * vec= new vector(2); stack * lis= new list; vec.push(3); vec.push(4); int size=vec.size(); cout<
-
Hi everybody. Can anybody help me please? :confused: Define a virtual class stack to define the stack popular operations • size() • push() • pop() • peak() • isEmpty() • isFull() Derive two classes from the virtual stack class, call the first class vectorStack and the second class listStack, use STL vector and list classes to implement the two derived classes. i tried this one but it's not working, do anybody have suggestions please /////////////////////////////////////// #include #include #include using namespace std; template class stack { private: public: virtual type size(); virtual void push( type e); virtual void pop( type & e ); virtual void peak(); virtual bool isEmpty(); virtual bool isFull(); }; template class vector ::public stack { public: void push(type v) { v.push_back(); } void pop(type v) { v.pop_back(); } bool isEmpty(type v) { return(v.empty()); } bool isFull(type vector) { vector.capacity(); } type size(type vec) { vec.size(); } }; template class list::public stack { public: void push(type v) { v.push_back(); } void pop(type v) { v.pop_back(); } bool isEmpty(type v) { return(v.empty()); } bool isFull(type vector) { vector.capacity(); } type size(type vec) { vec.size(); } }; void main() { stack * vec= new vector(2); stack * lis= new list; vec.push(3); vec.push(4); int size=vec.size(); cout<
Does your question relevant to Vista and then when post a code use of pre tags
pre
WhiteSky