5/5 – (1 vote)
● (10 points) Enter, compile, and execute the following C++ program.#include <iostreamusing namespace std;int main( int argc, char *argv[] ){cout << “Hello World!
”;}
● (40 points) Write a class, called Stack, in a file called Stack.h, that implements a stack of up to 1000 characters. You should include the following member functions in your class.#define STACK_CAPACITY 1000class Stack{public:Stack(); // constructor for a stackvoid push( char c ); // adds c to the top of the stackvoid pop(); // removes top elementchar top(); // returns the top elementbool isEmpty(); // returns true iff the stack is empty~Stack(); // destructor for a stack};
● (30 points) Write a main procedure, in a file called main.cpp, that repeatedly reads a character string from cin into a string variable and outputs the reverse by pushing the characters onto an instance of your stack class, then printing them as they are removed from the stack.
● (20 points) Modify your program to exit on end of file (when the user types a ^D, on unix, or ^Z, on the Windows).
Reviews
There are no reviews yet.