answersLogoWhite

0

Represent a stack in c plus plus?

Updated: 8/17/2019
User Avatar

Wiki User

10y ago

Best Answer

Use a vector with a base class type. Any objects derived from the base class can be pushed and popped from the vector just as you would from a stack.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Represent a stack in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How you use stack in c plus plus classes?

It would be easier to manipulate the stack in assembly language rather than C++.


What do a and b and c and d represent if a plus a and b plus a and b and c plus a and b and c and d equals 2006?

And how does this relate to coins?


Representation of stack data structure in c plus plus?

Stack is an abstract data type that allows you to input and output data in a way that the first data which was placed in the stack will be the last one to get out. We use physical examples of stack in our daily lives such as the stack of dishes or stack of coins where you only add or remove objects from the top of the stack. You can see the implementation in c++ in related links, below.


What is pop in C plus plus?

"Pop" allows you to remove items off of the stack. The stack is an area in memory that contains the information of a program, such as function names and instructions, the values of variables, etc. The opposite of pop is "push". This allows you to add items to the stack.


How do you determine when a stack is empty in c plus plus?

#include<iostream> #include<stack> #include<cassert> int main () { std::stack<unsigned> s; assert (s.empty()==true); s.push (42); assert (s.empty()==false); s.pop (); assert (s.empty()==true); }


In c plus plus what is meant by stack?

The stack is a region of memory organized as a first-in-last-out (LIFO) structure which stores return information, parameters, and local variables. Since it is a LIFO structure, it is nested, i.e. "stacked", similar to how a stack of papers on your desk would be stacked, and if you could only deal with the top-most paper on the stack. At the language level, C, C++, JAVA, etc., you generally do not even think about the implementation of the stack - it is just there - and it does what it needs in terms of return state, registers, parameters, and automatic or temporary variables.


'write a simple program for stack operation in c plus plus?

void push(int y) { if(top>stackSize) { cout<<"stack full"<<endl; return; } else { top++; stack[top]=y; } } int pop() { int a; if(top<=0) { cout<<"stack is empty"<<endl; return 0; } else { a=stack[top]; top--; } return(a); }


Does PlayStation plus stack?

Yes, it is possible to purchase, or 'stack', additional time to your Plus membership


How does C plus plus endeavor to represent the loop paradigm?

Iterative loops in C/C++ are represented by for(), while() and do...while() code blocks. Recursive loops are represented by functions calling themselves.


How do you refresh stack using library functions in C programming?

What do you mean by stack-refreshing? Anyway, there are no stack handling functions in the standard C library.


What is mapping exception in c plus plus?

There is no such exception in C++. It's probably a 3rd party or user-defined exception. Examine the call-stack to determine where the exception was caught -- that should help you determine where the exception was thrown.


How does c plus plus endeavor to represent the object oriented paradigm?

C++ endeavours to represent the object oriented programming paradigm through the use of classes. The four main pillars of OOP are encapsulation, inheritance, polymorphism and abstraction, which C++ primarily achieves through the use of classes, class hierarchies, virtual methods and templates.