Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

Queue

#include <iostream>
#include <queue>

using namespace std;

int main() {

  // create a queue of string
  queue<string> animals;

  // push elements into the queue
  animals.push("Cat");
  animals.push("Dog");
  
  cout << "Queue: ";

  // print elements of queue
  // loop until queue is empty
  while(!animals.empty()) {

    // print the element
    cout << animals.front() << ", ";

    // pop element from the queue
    animals.pop();
  }

  cout << endl;
 
  return 0;
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #Queue
ADD COMMENT
Topic
Name
3+2 =