P
pvonnied
Hi,
Once more a question (sorry for the different e-mail addresses [in
regard
to my other posts], here @ work we have to use Google to post to
newsgroups):
If I use an iterator, say from std::map, I initialize it like so:
<--- --->
std::map<int, myClass*> myCollection;
std::map<int, myClass*>::iterator it = myCollection.begin();
for(; it != myCollection.begin(); ++it) { // do something }
---><---
For which reasons C++ uses the syntax above (I guess
because we use templates) ? Why is it not possible to
use myCollection.iterator it = myCollection.begin(); like
a kind of an inner class (Java style...)?
That would eliminate the need to retype std::map<int, myClass*>...
just to get an iterator. I know that I could use a typedef...
Binary regards (as one suggested in stead of my Brgds tag ;-) ),
Peter
Once more a question (sorry for the different e-mail addresses [in
regard
to my other posts], here @ work we have to use Google to post to
newsgroups):
If I use an iterator, say from std::map, I initialize it like so:
<--- --->
std::map<int, myClass*> myCollection;
std::map<int, myClass*>::iterator it = myCollection.begin();
for(; it != myCollection.begin(); ++it) { // do something }
---><---
For which reasons C++ uses the syntax above (I guess
because we use templates) ? Why is it not possible to
use myCollection.iterator it = myCollection.begin(); like
a kind of an inner class (Java style...)?
That would eliminate the need to retype std::map<int, myClass*>...
just to get an iterator. I know that I could use a typedef...
Binary regards (as one suggested in stead of my Brgds tag ;-) ),
Peter