dan wrote:
> Hello,
> An Iterator class declares a data member that points to the current
> index of an array within a container class. It also implements a
> member function that determines whether or not the data member is
> pointing to the last index in the array using pointer arithmetic.
>
> class CIterator
> {
> public:
> CIterator(CContainer& c) : myContainer,
> mypData(myContainer.mypArray) {}
>
> void Reset() { mypData = myContainer.mypArray; }
> bool IsEnd()
> {
> return ((mypData - myContainer.mypArray) >=
> myContainer.mySize);
> }
>
> private:
> CContainer& myContainer;
> int *mypData;
> };
>
> My question is in regards to the way c++ points to memory. If {
> mypData = myContainer.mypArray; } assigns the address of the first
> element in the array to mypData, then how is it that ((mypData -
> myContainer.mypArray) >= myContainer.mySize); the first operand which
> is basically an address in memory, (correct?)
No, it's difference between two addresses. It's usually a signed
integer type called std:

trdiff_t (defined in <cstddef>).
> can relate to the second
> operand (mySize) which is an int with a relational operator? the 2
> data types don't seem compatible.
>
> Daniel