A type that represents the type of object stored as an element in a stack.

typedef typename Container::value_type value_type;

The type is a synonym for value_type of the base container adapted by the stack.

// stack_value_type.cpp
// compile with: /EHsc
#include <stack>
#include <iostream>

int main( )
   using namespace std;
   // Declares stacks with default deque base container
   stack<int>::value_type AnInt;
   AnInt = 69;
   cout << "The value_type is AnInt = " << AnInt << endl;

   stack<int> s1;
   s1.push( AnInt );
   cout << "The element at the top of the stack is "
        << ) << "." << endl;
The value_type is AnInt = 69
The element at the top of the stack is 69.

Header: <stack>

Namespace: std

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft