Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: C++ Design and implement a generic stack class. By using templates your stack has to be able to store any type of data. The

Language: C++ Design and implement a generic stack class. By using templates your stack has to be able to store any type of data. The underlying data structure should be an array. While designing and implementing your class you cannot use any of the container classes from the Standard Template Library (STL). Your class should support the following operations (read all the requirements before starting to write code): Stack(): this constructor initializes the stack to a size of 10. Stack(const Stack&): copy constructor, create a real copy of the stack. Stack(int size): this constructor sets the stacks size to the given size. bool push(T element): adds element to the top of the stack. It should return true, if the element has been successfully pushed. So as long as you do not provide an extend() method, you need to check for available space and return false if there is no more space. bool pop(T& out): pops an element from the top of the stack. The element is put into out. It should not crash if there are no elements on the stack, but rather return false, otherwise it should return true. T back(void): returns the data on the top of the stack, without changing the stack. int getNumEntries(): returns the number of entries of the stack at a given moment. Destructor for the template class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago