K
KK
Hello comp.lang.c++,
Is it possible to construct an iterator for a class that can traverse
through all the elements associated with that class?
Class AnotherDataType; //defined somewhere else
Class Crazy
{
int _num;
std::string _name;
unsinged int _index;
AnotherDataType _tmp;
Class Iterator
{
//define other necessary funcs elements
Iterator& operator++ () {
// IF the current element pointer is "_num" THEN return
pointer to "_name"
// IF the current element pointer is "_name" THEN return
pointer to "_index"
// IF the current element pointer is "_index" THEN return
pointer to "__tmp"
}
}
}
Any ideas on how to go about doing this?
Thanks.
-KK
Is it possible to construct an iterator for a class that can traverse
through all the elements associated with that class?
Class AnotherDataType; //defined somewhere else
Class Crazy
{
int _num;
std::string _name;
unsinged int _index;
AnotherDataType _tmp;
Class Iterator
{
//define other necessary funcs elements
Iterator& operator++ () {
// IF the current element pointer is "_num" THEN return
pointer to "_name"
// IF the current element pointer is "_name" THEN return
pointer to "_index"
// IF the current element pointer is "_index" THEN return
pointer to "__tmp"
}
}
}
Any ideas on how to go about doing this?
Thanks.
-KK