![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Professional Programmer
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 3
![]() |
Hey Grumpy!
Thanks for the great explanation... Ok, so i wasnt understanding the concept... Mmm, ok it's not good to derive! I dont want to embed the Iterator in the class because to use the Iterator would require: Myclass<int> myclass; ... Myclass<int>::Iterator it = myclass.begin(); id rather do Myclass<int> myclass; ... Iterator<int> it = myclass.begin(); so its easier to write the code??? that would require i write a template Iterator class, but then it would be hard to define how the Iterator works with certain types of containers since its a closed format??? what do you think??? thanks for the help! much appreciated! ![]() |
|
|
|
|
|
#12 |
|
Professional Programmer
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 3
![]() |
ok, i would guess that it would fit the container description better to have:
Container::Iterator it = mycontainer.begin(); mmm? |
|
|
|
|
|
#13 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I would suggest (and you might agree if you read the thread) that you are using the thread as a journal to record your musings and discuss your random thoughts. It would be much more effective to read some material and think solidly about it. Fifteen minutes or an hour between posts doesn't indicate that much of that its going on. Just a personal inference, of course.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#14 |
|
Professional Programmer
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 3
![]() |
yeah i suppose you are right DaWei...
i guess i talk too much :eek: gonna do some reading on this... will think long and hard... ill try only post tomorrow then! ![]() |
|
|
|
|
|
#15 |
|
Hobbyist Programmer
Join Date: Nov 2006
Location: 163H
Posts: 215
Rep Power: 3
![]() |
I have a question : What kind of iterator can i implement in a matrix?
C++ Annotations is a book for everyone. And you can find a section on iterators. Hope this helps. ![]()
__________________
You never test the depth of a river with both feet. The believer is happy. The doubter is wise. Free speech carries with it some freedom to listen. The next generation will always surpass the previous one. It`s one of the never ending cycles of life. |
|
|
|
|
|
#16 |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,292
Rep Power: 5
![]() |
I get the idea that you're trying to do this as a learning exercise, rather than to satisfy a requirement of some project. However, if I'm wrong, and you actually have a purpose in mind for it, then perhaps you should reflect on that purpose for a bit, and consider what type of iterator you need. For example, if your container is a queue of items to be processed, all you really need to be able to do is a) create your iterator that points to the queue's beginning, b) increment your iterator, and c) detect when it's hit the end. On the other hand, if your container is an abstraction of an array (like a vector), then you need to implement random-access functionality, which may make things more complicated.
__________________
Java? Rant? Me? Noooo.... |
|
|
|
|
|
#17 |
|
Professional Programmer
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 3
![]() |
Hey,
Ok, i did some reading - guess it all makes sense! Thanks Pegasus - ill have a look at the book if i can! to lectricpharaoh - yeah i guess I didnt think enough about this... mmm, bad move! thanks guys for help! PS: im also interested in hearing about an iterator for a matrix... that would be tricky - maybe a candidate for up and down iterator ![]() guess i got you! haha! :banana: |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to create office xp like menus and other custom controls | some1 | C++ | 5 | Nov 8th, 2005 3:28 PM |
| question: usage of delagates and custom events | melbolt | C# | 1 | Oct 3rd, 2005 8:17 PM |
| Using Iterator on a HashMap | Hockeyman | Java | 3 | Jun 15th, 2005 5:31 AM |
| Cast stl iterator to integer | iignotus | C++ | 11 | May 7th, 2005 10:57 PM |
| how do i make custom functions | cloud- | Visual Basic | 3 | Jan 11th, 2005 2:14 PM |