// project2.cpp : Defines the entry point for the console application.
//HELP ME I NEED TO DETERMINE BOUNDARY CONDITIONS IN THE
//STACK
//I ALSO NEED TO CHECK IF STACK IS EMPTY..SHOULD I MAKE //ANOTHER FUNCTION
//#include "stdafx.h"
#include "iostream.h"
class Stack {
private:
char *top;
char *bottom;
public:
Stack();
~Stack();
void push(char); // add a char to the stack
char pop(); // remove a char from the stack
};
Stack::Stack()
{
top = new char[20]; //dynamic memory allocation
bottom = top; //set bottom = top
}
Stack::~Stack()
{
delete top;
}
void Stack:ush( char c )
{
determine boudary conditions
if (*top > 1 && *top < 100)
{
++top;
*top = c;
}
}
char Stack:op()
{
// determine how to verify stack is not empty
//hint: check pointers..if pointers are equal.....
//if empty return character you defined
char ch;
ch = *top;
--top;
return(ch);
}
int main(int argc, char* argv[])
{
cout<<"Hello World!\n";
Stack *p_Stack;
p_Stack = new Stack;
p_Stack->push('a');
p_Stack->push('b');
p_Stack->push('c');
p_Stack->push('d');
cout << p_Stack->pop();
cout << endl;
return 0;
}



LinkBack URL
About LinkBacks
ush( char c )



