New course! Every coder should learn Generative AI!
Try a free lesson0
<typename T> vs <class T>
I know I just posted another question. Bear with me. Lol So in the c++ templates tutorial, they mention the existence of another definition, where instead of using <class T>, you can use <typename T>. All that is said about typename is that typename and class are similar. What's the difference between the two? Please provide examples if possible.
1 Answer
+ 1
There is no specific difference between class and typename in a template parameter. typename however, is possible in another context when using templates - to hint at the compiler that you are referring to a dependent type. Without typename, the compiler can't tell in general whether you are referring to a type or not.