Results 1 to 2 of 2
Hybrid View
-
11th November 2008 09:22 #1Registered User
Join Date: Dec:2006
Location: SOFIA
Posts: 18
Ïîìîù ñúñ implement the stack ADT using the STL vector class, C++
Àêî ìîæå íÿêîé äà ìè ïîìîãíå äà íàïèùà ñëåäíàòà ïðîãðàìà íà C++ ùå ñúì ìó ìíîãî áëàãîäàðåí:
Write a complete program in C++ with at least one example of using all interface functions of the specified below ADT ( Abstract Data Type)
You should implement the stack ADT using the STL vector class.
Ìåðñè
-
11th November 2008 10:16 #2Registered User
Join Date: Dec:2006
Location: SOFIA
Posts: 18
çà ñåãà èìàì òîâà
Code:#ifndef SIMPLE_STACK_LIFO #define SIMPLE_STACK_LIFO #include <vector> template <class T> class stack{ public: typedef std::vector<T> Container; typedef typename Container::size_type size_type; typedef typename Container::value_type value_type; typedef typename Container::reference reference; typedef typename Container::const_reference const_reference; explicit stack(const size_type nSize = 100){ m_vContainer.reserve(nSize); } void push(const_reference obj){ m_vContainer.push_back(obj); } reference top(){ return m_vContainer.back(); } const_reference top() const{ return m_vContainer.back(); } void pop(){ m_vContainer.pop_back(); } bool empty() const{ return m_vContainer.empty(); } size_type size() const{ return m_vContainer.size(); } protected: Container m_vContainer; }; #endif // SIMPLE_STACK_LIFO




Reply With Quote
Lenovo ThinkPad 15 èëè IdeaPad 15
5th May 2023, 22:16 in Ìîáèëíè êîìïþòðè