Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help! it's not compiling.... #ifndef INTSTACK_H_INCLUDED #define INTSTACK_H_INCLUDED class IntStack { private: int *stackArray; // Pointer to the stack array int stackSize; // The

Please help! it's not compiling....

#ifndef INTSTACK_H_INCLUDED #define INTSTACK_H_INCLUDED

class IntStack { private: int *stackArray; // Pointer to the stack array int stackSize; // The stack size int top; // Indicates the top of the stack

public: // Constructor IntStack(int);

// Copy constructor IntStack(const IntStack &);

// Destructor ~IntStack();

// Stack operations void push(int); void pop(int &); bool isFull() const; bool isEmpty() const; };

#endif // INTSTACK_H_INCLUDED

-----------------------------------------------------------------------------------------

#ifndef MATHSTACK_H_INCLUDED #define MATHSTACK_H_INCLUDED

#include "IntStack.h" // Specification file for the MathStack class

class MathStack : public IntStack { public: // Constructor MathStack(int s) : IntStack(s) {}

// MathStack operations void add(); void sub(); };

#endif // MATHSTACK_H_INCLUDED

---------------------------------------------------------------------------------------------------------------------

#include "IntStack.h" #include

using namespace std;

int main() { int catchVar; // To hold values popped off the stack

// Create a MathStack object. MathStack stack(5);

// Push 3 and 6 onto the stack. cout << "Pushing 3 "; Stack.push(3); cout << "Pushing 6 "; stack.push(6);

// Add the two values. stack.add();

// Pop the sum off the stack and display it. cout << "The sum is "; stack.pop(catchVar); cout << catchVar << endl << endl;

// Push 7 and 10 onto the stack cout << "Pushing 7 "; stack.push(7); cout << "Pushing 10 "; stack.push(10);

// Subtract 7 from 10. stack.sub();

// Pop the difference off the stack and display it. cout << "The difference is "; stack.pop(catchVar); cout << catchVar << endl; return 0; }

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

2. Place a value on the outcomes.

Answered: 1 week ago