intstack.h cannot be changed

class IntStack

   int *stackArray;  // Pointer to the dynamically allocated stack array
   int stackSize;    // The stack size
   int top;          // Indicates the top of the stack

   // Constructor

   // Destructor

   // Stack operations
   void push(int);
   int pop();
   bool isFull() const;
   bool isEmpty() const;
intstack.cpp cannot be changed

using namespace std;

IntStack::IntStack(int size)
    stackArray = new int[size];
    stackSize = size;
    top = -1;

    delete [] stackArray;

void IntStack::push(int num)
    assert (!isFull());  // will exit program if this happens
    stackArray[top] = num;

int IntStack::pop()
    assert(!isEmpty());  // will exit program if this happens
    int num = stackArray[top];
    return num;

bool IntStack::isFull() const
    return (top == stackSize - 1);

// Member funciton isEmpty returns true if the stack *
// is empty, or false otherwise.                     *

bool IntStack::isEmpty() const
    return (top == -1);

int main()
    char filename;
    ifstream inFile;
    cout << "Enter the filename.";
    cin, filename;

    int c;

    if (!inFile)
        cout << "File could now be opened. Program terminated."<< endl;
        return 1;

    return 0;
3 Years
Discussion Span
Last Post by HenryR7
Given a text file, your program will determine if all the parentheses, curly braces, and 
square brackets match, and are nested appropriately. Your program should work for 
mathematical formulas and computer programs. 
Your program should read in the characters from the file, but ignore all characters 
except for the following: 
{ } ( ) [ ] 

Your program should prompt the user to enter a filename. It should then try to open 
the file and then check it make sure the brackets all match appropriately. If they all 
match, the program should output a message saying so. If not, the program should 
output an appropriate error message. 
There are three types of errors that can happen (and they can happen with any kind of 
! missing } : if you reach the end of the file, and there is an opening { that was 
never matched, like: int main () { x[size]=10; 
expected } but found ) : this is a wrong closing bracket, like: {x[i]=10;)... 
unmatched } : this occurs if there is a closing bracket but not an opening bracket 
(not even one of the wrong kind), like: int main () { x[i]=10; } }... 

on number 74, we dont read data like that. it must be cin>> filename
Also this is purely a homework that you have not touched. Its partially given by your instructor for you to do the res so be kind and show us what you have included so far ok?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.