Use of Typename Keyword Sample

Description

A type parameter for a template may be bound to a class argument, or to a variety of other types such as int or void. Consider an example such as:

	template <class T> class A {
		T::X a;
	};
If T is bound to a class type, then T::X could possibly refer to a qualified name, whereas if T is a fundamental type such as int, then T::X is meaningless and invalid. But it's not possible to know the type of T until instantiation is done, and some mechanism is needed to specify types. The typename keyword is used to indicate that a qualified name is a type. Without use of the keyword a type parameter name is assumed not to refer to a type.

Concept

The sample program defines a class A, with a nested type SH in it. A template B is instantiated with A as an argument. The type T::SH cannot be used in B without prefacing it with typename, that indicates that T refers to a type.

Supported
Supported
Supported