Member parent is a reference. Reference members
must be initialized during construction.
The C++ Standard Library iterators are different. Many classes.
Compile-time polymorphism to enable generic algorithms.
http://www.cplusplus.com/reference/iterator/iterator/
http://www.cplusplus.com/reference/iterator/RandomAccessIterator/
Yes, you can default construct a STL iterator, but where does it point to? Nowhere. It is like an invalid pointer.
It should not be dereferenced or compared before it is set to point to a container.
How does one usually use a STL iterator?
1 2 3
|
auto it = foo.begin();
if ( it != foo.end() ) {
// ...
|
On line 1 I copy construct an iterator from iterator returned by foo.begin().
foo.begin() and foo.end() do create iterators that point to object foo.
I do not care whether they use iterator constructor that takes arguments or default construct and then set members. It is likely that an STL iterator holds a pointer.
STL iterators are flexible. You can reuse same iterator variable to point to different containers at different times. The feature may not yield much benefit, but at least it allows you to make catastrophic mistakes, just like with raw pointers.
Your Vector<T>::iterator is more strict. It automatically prohibits some error types.
It is a design philosophy question, whether to enforce syntactically The One Proper Use of your classes, or to allow much more leeway for the programmer.