LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-16-2005, 05:04 PM   #1
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 438

Rep: Reputation: 30
Basic C++ question


I'm new to C++, so bear with me. I'm using a queue from the standard template library. I'm using it with type Node*. I'm wondering how to return the top item. I noticed that the pop() is of type void so this is what I've done:

Code:
Node* removeNext(){
            
           Node* node = 0;
           
             if(!fringe.empty()){
                           node = fringe.front();
                           fringe.pop();
             }
     
             return node;

}
is this the right way to try to pop the top item off?


Last edited by oulevon; 02-16-2005 at 05:05 PM.
 
Old 02-16-2005, 05:55 PM   #2
dakensta
Member
 
Registered: Jun 2003
Location: SEUK
Distribution: Debian & OS X
Posts: 194

Rep: Reputation: 35
Yes, always call front() and pop() to process and remove.

That said, it borders on trivial to reimplement a queue if you want your own interface.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic question a2715mt Linux - Newbie 9 08-25-2004 08:39 AM
*very* basic c question usernamed Programming 9 08-21-2003 08:29 AM
basic question jaina2 Linux - Newbie 1 07-26-2003 02:44 AM
basic question kurgan70 Linux - General 2 12-06-2001 03:42 PM
Very Basic Question Terri Linux - Newbie 6 10-17-2001 01:31 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration