다음을 통해 공유


stack::empty

스택이 비어 있는 경우 테스트 합니다.

bool empty( ) const;

반환 값

true 이면 스택이 비어 있으면 false 이면 스택이 비어 있지 않은 경우.

예제

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

int main( )
{
   using namespace std;
   // Declares stacks with default deque base container
   stack <int> s1, s2;

   s1.push( 1 );

   if ( s1.empty( ) )
      cout << "The stack s1 is empty." << endl;
   else
      cout << "The stack s1 is not empty." << endl;

   if ( s2.empty( ) )
      cout << "The stack s2 is empty." << endl;
   else
      cout << "The stack s2 is not empty." << endl;
}
  
  

요구 사항

헤더: <stack>

네임 스페이스: std

참고 항목

참조

stack Class

stack::top 및 stack::empty

표준 템플릿 라이브러리