C++ > Beginners Lab Assignments
Implementing Stack using Class (with constructor etc).
Implementing Stack using Class (with constructor etc). # include
# include
# define SIZE 20 class stack { int a[SIZE]; int tos; // Top of Stack public: stack(); void push(int); int pop(); int isempty(); int isfull(); }; stack::stack() { tos=0; //Initialize Top of Stack } int stack::isempty() { return (tos==0?1:0); } int stack::isfull() { return (tos==SIZE?1:0); } void stack::push(int i) { if(!isfull()) { cout<<"Pushing "<
C++ Codes
Algorithms
Beginners
Code Snippets
Graphics
Data Structures
Games
Mathematics
Miscellaneous