I am trying to use the same variable for both iterator and reverse iterator. However, I cannot find the common base class to do so. I want to do something like this:
string a;
....
string::iterator i;
if (....)
i = a.begin();
else
i = a.rbegin(); //Error
....
Is there a good way of doing this?
iteratorandreverse_iteratorbe of compatible types. They are not necessarily classes either, so may not have a common base. Try do have characteristics/traits in common though.