Welcome to pickSourcecode.com Login | Register    
pickZy.com
 Home  | search  | games  | General  | C  | C++  | Java  | Php  | Networking  | Visual Basic  | VC++  | Win32  | MFC  | JavaScript  | Jobs  | JavaScript  | Post jobs
cpp basic queue examples and tutorials       Share
2008-09-28 |  RatheeshTR  | Viewed: 152  |    0

#include <iostream>
#include <queue>
using namespace std;


template<class T, class C>

void ShowQueue(const queue<T, C>& aQueue);

int main()
{

//  create  a  integer  queue
queue<int> qInt;

cout << "Queue qInt created:\n";

ShowQueue(qInt);


//  push  elements  into  the  queue
for (unsigned int i = 1; i < 5; ++i)
qInt.push(i * 2);

cout << "qInt:\n";

ShowQueue(qInt);


//  modify  the  first  and  last  elements
qInt.front() = 20;

qInt.back() = 30;

cout << "The first and last elements modified:\n";

ShowQueue(qInt);


//  remove  first  element  from  the  queue
qInt.pop();

cout << "After one pop() operation\n";

ShowQueue(qInt);


return 0;

}


//
//  Display  queue  elements
//
template<class T, class C>

void ShowQueue(const queue<T, C>& aQueue)
{

cout << "size() = " << aQueue.size();

if (!aQueue.empty())
{

cout << "\tfront() = " << aQueue.front();

cout << "\tback() = " << aQueue.back();

}

cout << "\n\n";

}


Comments:





Submit comment's

Type:

User Comment's:

Submitted By:
Prof: Software
Tech: C ,Cpp
Send Mail: malathi.v



Related topics
Stack Implementation
cpp stack example

General Topics
iphone free apps 2012 for entertainment use
iphone apps 2012 for entertainment use
recursively delete subdirectories
superb sentences by 7 superb persons
ultimate love letter…
i am sharing my work strategy
to return the key board
freelance writers

Web site contents © Copyright 2007, All rights reserved.
Help | Terms and Conditions | Privacy Policy | About Us