Differences between 2 pointers of a template

  • A+
Category:Languages

I want to know if there is any difference between 2 pointers (as data members) in a template class. For example:

template <typename E> class Link { private:     E element;     Link* a;     Link<E>* b; }; 

Is "a" analogous to "b", I wonder?

 


Both forms are valid. When the name of a class template is used inside the class template scope without template arguments, it resolves to the name of the "current" template specialization.

a and b have the same type.

It's the same rule that makes it possible for us to write for example:

template<typename T> Foo<T>::Foo(Foo const&) = default; 

... instead of the more verbose:

template<typename T> Foo<T>::Foo(Foo<T> const&) = default; 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: