Поделиться через


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

Стандартная библиотека шаблонов