intstack.h cannot be changed
class IntStack
private:
int *stackArray; // Pointer to the dynamically allocated stack array
int stackSize; // The stack size
int top; // Indicates the top of the stack
public:
// Constructor
IntStack(int);
// Destructor
~IntStack();
// 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;
}
IntStack::~IntStack()
{
delete [] stackArray;
}
void IntStack::push(int num)
{
assert (!isFull()); // will exit program if this happens
top++;
stackArray[top] = num;
}
int IntStack::pop()
{
assert(!isEmpty()); // will exit program if this happens
int num = stackArray[top];
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;
inFile.open("testing.txt");
int c;
if (!inFile)
{
cout << "File could now be opened. Program terminated."<< endl;
return 1;
}
else
inFile.close();
return 0;
}
HenryR7
0
Newbie Poster
Recommended Answers
Jump to Poston 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?
All 4 Replies
HenryR7
0
Newbie Poster
richieking
44
Master Poster
kal_crazy
13
Junior Poster
HenryR7
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.