   Typename
  Hi everyone,I've recently started learning about templates, and I have a question. I've seen templates declared astemplate<typename T>at times, and at other times it's declared astemplate<class T>What's the difference?Thanks.   
  They function exactly the same, afaik   ;  They're equivalent. There are two reserved words that mean the same thing in this context for historical reasons; see here;  There is no difference. Both typename T and class T mean "a type named T" in this context.   ;  Thanks for the replies, that makes sense now.One last thing. WithT::A *aObjandtypename T::A* a6;Would there be an error if T did not contain an A?   ;Quote:Original post by AiwendilThanks for the replies, that makes sense now.One last thing. WithT::A *aObjandtypename T::A* a6;Would there be an error if T did not contain an A?Of course.Their example about using class instead of typename is one of the more interesting cases, and one that can cause confusion.The first example says to take the value of A within the scope T, and multiply it by aObj.  It is a subtle error, and generally not what the programmer meant.  The code will work if you meant to do this:class T {  public:   const int A = 4;};If A is not a value, the code should not compile.The second says to create a pointer of T::A, which must be a type.class T { public:  struct A { ... };};If A is not a type, the code should not compile.   