I created a vector of an object. Then I had an iterator of the vector which lets me access each object in the vector. If I create a pointer iterator and set it to the address of one of these non-pointer iterators, how can I access a child of the object using the pointer?
Ex: I have this object:
1 2 3 4 5 6 7
struct obj
{
int k;
char t;
obj* next;
};
std::vector<obj> ovec;
using a for-loop, I add say 2 instances of this object to a vector
1 2 3 4
for (int k..k < 2..)
{
ovec.push_back(obj)
}
I get an iterator of ovec std::vector<obj>::iterator oti = ovec.begin()
I get a pointer iterator std::vector<obj>::iterator* pti = oti;
How do I access next using pti?
I mean if this oti->next = 0; works, why does this *pti->next = 0; not work?
I am trying to implement dfs so I want to use iterator pointers intead of actual iterators. But this seems a bit complicated, so I will just use normal iterators