stack::stack (STL/CLR)

建構容器配接器物件。

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

參數

  • right
    若要複製的物件。

  • 自動換行
    若要使用的包裝的容器。

備註

建構函式:

stack();

建立空的包裝的容器。您可以用它來指定空的初始受控制的序列。

建構函式:

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

會建立一個包裝的容器,是一份right.get_container()。您會用它來指定初始的受控制的序列是一份由堆疊物件來控制序列的right。

建構函式:

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

會建立一個包裝的容器,是一份right->get_container()。您會用它來指定初始的受控制的序列是一份由堆疊物件來控制序列的*right。

建構函式:

explicit stack(container_type% wrapped);

使用現存的容器wrapped為包裝的容器。您可以用它來建構堆疊,以從現有的容器。

範例

// 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); 
    } 
 
  

需求

標頭: < cliext/堆疊 >

Namespace: cliext

請參閱

參考

stack (STL/CLR)

stack::assign (STL/CLR)

stack::generic_container (STL/CLR)

stack::operator= (STL/CLR)