You are wrong on that.
With your current code, creating an IntFile::iterator like this:
(IntFile::iterator i = Obj1.begin();
gives you an IntFile::iterator
identical to creating one like this:
(IntFile::iterator i = Obj2.begin();
Your IntFile::iterator object doesn't know what created it. You used a function from Obj1 to create the iterator, but that's irrelevant. Look at what IntFile::iterator knows about:
1 2
|
int index = 0;
int value = 0;
|
These are
IntFile::iterator
's member variables. This is everything an
IntFile::iterator
knows about the universe. It has no way of knowing it is associated with Obj1. It has no record of Obj1.
Consider if this was the IntFile::iterator's member variables:
1 2 3
|
int index = 0;
int value = 0;
IntFile* the_Intfile_I_am_associated_with;
|
If you populated that pointer variable,
the_Intfile_I_am_associated_with
, suddenly the IntFile::iterator does know which IntFile it is associated with, and will be able to call class functions on that IntFile.