Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Latest commit

History

History
29 lines (23 loc) 路 734 Bytes

empty.md

File metadata and controls

29 lines (23 loc) 路 734 Bytes

empty

Description : The list::empty() is a built-in function in C++ STL is used to check whether a particular list container is empty or not.

Example :

    // Creating a list 
    std::list<int> demoList; 
  
    // check if list is empty 
    if (demoList.empty()) 
        std::cout << "Empty List\n"; 
    else
        std::cout << "Not Empty\n"; 
  
    // Add elements to the List 
    demoList.push_back(10); 
    demoList.push_back(20); 
    demoList.push_back(30); 
    demoList.push_back(40); 
  
    // check again if list is empty 
    if (demoList.empty()) 
        std::cout << "Empty List\n"; 
    else
        std::cout << "Not Empty\n"; 
         

Run Code