I'm using C++. I would like to design a class that I can walk through similarly to std::vector, i.e.:
class Something
{
void AddABunchOfObjects() {...}
//
// Is it possible to do the below, in some form or syntax?
//
operator for (?????) {return GetObjectAtIterator();}
};
Somethign my_custom_object_container;
my_custom_object_container.AddABunchOfObjects();
for (auto &objectname : my_custom_object_container)
I don't want to use std::vector because there's a little extra work I want done with each fetch (and why can't we override/inherit std's classes anyway? Whence object-oriented? /rant)
I can't seem to find this info online, if it's possible (or I'm not using the right keywords). Is there some sort of operator override or equivalent that can be used to make a class able to iterate?