How to print a stack using arrays in c++ -


I've added all the required functions - e.g. Push, Pop and Print - In my program, but unable to print stack output on the console screen. I have created three separate files with classes, functions and main files. I want to know that I have inserted the element inserted in the stack successfully. So I have to print the updated stack so I have to print the updated stack.

stack.h

  #ifndef Stack_H #define Stack_H using namespace std; Class Stack {Private: // Int construction capacity = 50; Int stack [50]; integer number; Int top; Integer maximum; Public: // This is the function where the focus is (); // constructor empty push (int data); Zero pop (int.dellata); Zero print-stack (); }; #endif   

stack.cpp

  #include & lt; Iostream & gt; # Include & lt; Fstream & gt; # Include & lt; Cstdlib & gt; # Include & lt; Vector & gt; #include & lt; String & gt; # Include "Stack H" using the namespace std; Stack :: Stack () {top = -1; }; Zero Stack :: Push (int data) {top ++; CIN & gt; & Gt; Data; Heap [top] = data; Count ++; Cout & lt; & Lt; "Successfully inserted:" & lt; & Lt; Data & lt; & Lt; Endl; } Zero stack :: pop (int item) {if (top <0) {cout < & Lt; "Stack is empty"; } Other {items = stack [top]; Top--; Cout & lt; & Lt; "Deleted elememt is:" & lt; & Lt; Item & lt; & Lt; Endl; }} Zero stack :: printstacks () (if (top ;)} {cout   
< P> main.cpp
  #include & lt; cstdlib & gt; #include & lt; iostream & gt; #include & lt; stack & gt; #name using location std Include "stack h"; int main () {pile r; int ele; int data; cout    

Can be defined by

  zero printstacks (for {{int i = top; I & gt; = 0; -i) std :: cout & lt; & Lt; Stack [i] & lt; & Lt; ''; }   

Note that pop has no meaning. At least it should be declared as

  zero pop (int and deldata);    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -