다음을 통해 공유


stack::push

스택의 맨 위 끝에 요소를 추가합니다.

void push(
   const Type& _Val
);

매개 변수

  • _Val
    스택 맨 위에 추가 되는 요소입니다.

설명

스택 맨 최근에 추가한 요소가 차지 하는 위치 이며 끝 컨테이너의 마지막 요소입니다.

예제

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

int main( )
{
   using namespace std;
   stack <int> s1;

   s1.push( 10 );
   s1.push( 20 );
   s1.push( 30 );

   stack <int>::size_type i;
   i = s1.size( );
   cout << "The stack length is " << i << "." << endl;

   i = s1.top( );
   cout << "The element at the top of the stack is "
        << i << "." << endl;
}
  
  

요구 사항

헤더: <stack>

네임 스페이스: std

참고 항목

참조

stack Class

표준 템플릿 라이브러리