#include#include int main() { std::queue q; if(q.empty()) { std::cout << "Queue is empty" << std::endl; } else { std::cout << "Queue is not empty" << std::endl; } return 0; }
#includeThis example creates a queue and adds three elements to it. It then uses the `empty()` function to check if it is empty. Since it has elements in it, it prints "Queue is not empty" to the console. The `queue` and `iostream` libraries are used in both examples.#include int main() { std::queue q; q.push(1); q.push(2); q.push(3); if(q.empty()) { std::cout << "Queue is empty" << std::endl; } else { std::cout << "Queue is not empty" << std::endl; } return 0; }