| | |
A little help traversing through a queue please
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 31
Reputation:
Solved Threads: 0
All this function is supposed to do is count each node in the queue and return the number of nodes.
I am not sure how I am supposed to traverse through the queue counting each node.
I 2 private class objects frontPtr, and rearPtr to use. am I even close on this? if more information is needed I can put it here.
c++ Syntax (Toggle Plain Text)
template<class SomeType> int TemplateQ<SomeType>::Size() const { int numberOfChars = 0; QueueNode<SomeType>* countPtr; if(IsEmpty) return 0; while(countPtr != rearPtr) { countPtr = frontPtr->data; numberOfChars ++; } }
I am not sure how I am supposed to traverse through the queue counting each node.
I 2 private class objects frontPtr, and rearPtr to use. am I even close on this? if more information is needed I can put it here.
Last edited by JustLearning; Oct 21st, 2008 at 3:38 pm.
•
•
Join Date: Sep 2008
Posts: 31
Reputation:
Solved Threads: 0
so then will this work
c++ Syntax (Toggle Plain Text)
template<class SomeType> int TemplateQ<SomeType>::Size() const { int numberOfChars = 0; QueueNode<SomeType>* countPtr; if(IsEmpty) return 0; while(countPtr != frontPtr) { countPtr = lastPtr->data; countPtr = countPtr->nextPtr; numberOfChars ++; } }
![]() |
Other Threads in the C++ Forum
- Previous Thread: C++ Logic Fuction Error
- Next Thread: Having trouble with a loop.(For a class)
Views: 617 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph homeworkhelp iamthwee ifstream input int java lib library lines list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct temperature template templates text tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






