Class Names in Class Templates Without Template Parameters
Consider a class template defined as follows:
<code class="cpp">template <typename E> class Link { public: E element; Link* next; // No typename argument here };</code>
The code you provided features a public member Link* next without a typename argument. This is known as an "injected class name."
According to [temp.local], when the injected class name is used within the scope of the class, it is equivalent to the class name followed by angle brackets containing the template parameters of the class. In this case, Link effectively becomes Link
Therefore, the expression Link* next within the Link class is equivalent to Link
The above is the detailed content of How do Class Names in Class Templates Work Without Template Parameters?. For more information, please follow other related articles on the PHP Chinese website!