friend class AIterator<T>;
12345
template<class T> AIterator<T>::AIterator(ASet& friendVar) { otherPtr = friendVar.sp;//sp is from protected section in ASet Class }
123456789101112131415161718192021222324
template < typename T > struct ASet { // ... struct AIterator // AIterator is a member of ASet<T> { AIterator( ASet<T>& set ) ; // ... T* other_ptr ; }; AIterator begin() { return AIterator(*this) ; } // ... protected: T* sp = nullptr ; }; template < typename T > ASet<T>::AIterator::AIterator( ASet<T>& set ) : other_ptr( set.sp ) {}