stack::stack (STL/CLR)

Constructs a container adapter object.

    stack();
    stack(stack<Value, Container>% right);
    stack(stack<Value, Container>^ right);
    explicit stack(container_type% wrapped);

Parameters

  • right
    Object to copy.

  • wrapped
    Wrapped container to use.

Remarks

The constructor:

stack();

creates an empty wrapped container. You use it to specify an empty initial controlled sequence.

The constructor:

stack(stack<Value, Container>% right);

creates a wrapped container that is a copy of right.get_container(). You use it to specify an initial controlled sequence that is a copy of the sequence controlled by the stack object right.

The constructor:

stack(stack<Value, Container>^ right);

creates a wrapped container that is a copy of right->get_container(). You use it to specify an initial controlled sequence that is a copy of the sequence controlled by the stack object *right.

The constructor:

explicit stack(container_type% wrapped);

uses the existing container wrapped as the wrapped container. You use it to construct a stack from an existing container.

Example

// cliext_stack_construct.cpp 
// compile with: /clr 
#include <cliext/stack> 
#include <cliext/vector> 
 
typedef cliext::stack<wchar_t> Mystack; 
typedef cliext::vector<wchar_t> Myvector; 
typedef cliext::stack<wchar_t, Myvector> Mystack_vec; 
int main() 
    { 
// construct an empty container 
    Mystack c1; 
    System::Console::WriteLine("size() = {0}", c1.size()); 
 
// construct from an underlying container 
    Myvector v2(5, L'x'); 
    Mystack_vec c2(v2);     
    for each (wchar_t elem in c2.get_container()) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// construct by copying another container 
    Mystack_vec c3(c2); 
    for each (wchar_t elem in c3.get_container()) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// construct by copying another container through handle 
    Mystack_vec c4(%c2); 
    for each (wchar_t elem in c4.get_container()) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
size() = 0
 x x x x x
 x x x x x
 x x x x x

Requirements

Header: <cliext/stack>

Namespace: cliext

See Also

Reference

stack (STL/CLR)

stack::assign (STL/CLR)

stack::generic_container (STL/CLR)

stack::operator= (STL/CLR)