Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include <queue> //cola
- template <class Tipo>
- class Cola : private queue<Tipo> {
- public:
- Tipo extraer(){
- Tipo valor = this->front();
- this->pop();
- return valor;
- }
- void agregar(Tipo valor){
- this->push(valor);
- }
- bool vacia(){
- return this->empty();
- }
- };
- int main()
- {
- //Utilizando librería STL
- queue<int> cola;
- cola.push(1);
- cola.push(2);
- cola.push(3);
- cola.push(4);
- while(!cola.empty()){
- cout << cola.front();
- cola.pop();
- }
- while(!cola.empty()){
- cout << cola.front();
- cola.pop();
- }
- //Clase COLA Utilizando librería STL
- Cola<int> miCola;
- miCola.agregar(11);
- miCola.agregar(12);
- miCola.agregar(13);
- miCola.agregar(14);
- while(!miCola.vacia())
- cout << miCola.extraer()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement