Closed swagger20 closed 10 months ago
@swagger20, you were using a pretty old version of PSReadLine (2.0.0-beta2 or prior), and it's likely that the issue was fixed in a newer version. Please upgrade to the 2.3.4 version of PSReadLine from PowerShell Gallery. See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.
Prerequisites
Exception report
Screenshot
Environment data
Steps to reproduce
include
using namespace std; class Stack{ public: int top; int *arr; int size; Stack(int size){ arr=new int[size]; this->size=size; top= -1; } //functions void push(int data){ //2 scenarios: space available nd space not available i.e. if stack is already full or a empty space is there for insertion of an element if(size-top> 1){ //if space is available then top index is increased and in the array at that index new element will be inserted top++; arr[top]= data; } else{ //if space is not available cout<<"Stack overflow"<<endl; }
} void pop(){ if(top==-1){ //if stack is already empty, no element is there to remove cout<<"Stack Underflow"<<endl; } else{ //This will eventually point to the previous element of the already old pointed top just top-- will now point to the previous element it will give the index of that previous element top--; } } int getTop(){ if(top==-1){ cout<<"There is no elemet in the stack"<<endl; } else{ return arr[top]; } } int getsize(){ //This will give the no. of valid elements present in the stack top to inde ko bta hi rha hh to usme +1 kr do it will give you the total element sof the stack bcoz top hi apko last element ka index deta hh return top+1; } bool isempty(){ if(top==-1){ return 1; } else return 0; } }; int main(){ //stack creation we have to give the size of the array as in the constructor we have defined the paramter of size so size of array is passed of 10
Stack s(4); //insertion s.push(34); s.push(21); s.push(70); s.push(90); s.push(30); while(s.isempty()!=1){ cout<<s.getTop()<<" "; s.pop(); } cout<<endl; cout<<"Size of stack as all the elemnts are removed bcoz of popping them to get them printed:"<<s.getsize(); s.pop();
return 0; }
Expected behavior
NA
Actual behavior
NA