Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 17th, 2007, 7:43 AM   #11
rwm
Professional Programmer
 
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 3 rwm is on a distinguished road
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!
rwm is offline   Reply With Quote
Old May 17th, 2007, 7:57 AM   #12
rwm
Professional Programmer
 
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 3 rwm is on a distinguished road
ok, i would guess that it would fit the container description better to have:

Container::Iterator it = mycontainer.begin();

mmm?
rwm is offline   Reply With Quote
Old May 17th, 2007, 9:49 AM   #13
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old May 17th, 2007, 9:55 AM   #14
rwm
Professional Programmer
 
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 3 rwm is on a distinguished road
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!
rwm is offline   Reply With Quote
Old May 17th, 2007, 12:02 PM   #15
pegasus001
Hobbyist Programmer
 
pegasus001's Avatar
 
Join Date: Nov 2006
Location: 163H
Posts: 215
Rep Power: 3 pegasus001 is on a distinguished road
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.
pegasus001 is offline   Reply With Quote
Old May 17th, 2007, 8:10 PM   #16
lectricpharaoh
SEXY SHOELESS GOD OF WAR!
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,292
Rep Power: 5 lectricpharaoh will become famous soon enough
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....
lectricpharaoh is offline   Reply With Quote
Old May 18th, 2007, 3:51 AM   #17
rwm
Professional Programmer
 
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 3 rwm is on a distinguished road
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:
rwm is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:46 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC