1, Type Description Typedef
The format of the type of type is: typedef type definition name; Type Description Only a new name of a data type is defined instead of defining a new data type. Define names indicating this type of new name. For example: use the following statement to define a new name: typedef int linened_int; After use instructions, Signed_INT has become the synonym of int, which can be used to define integer variables with SIGNED_INT. For example: Signed_INT I, J; (equivalent to INT I, J). But Long Signed_INT I, J; is illegal. TypedEf can also be used to explain the structure, joint, and enumerations and classes. Description A structure is: typedef struct {data type member name; data type member name; ...} Structure name; at this time, the structural variable can be defined directly with the structural name. For example: TypedEf struct {char name [8]; int class; char Subclass [6]; float math, phys, cym, eNGL, BIOL;} student; student liuqi; then LiUQi is defined as structural arrays and structural pointers. 2, type explanation TYPENAME
The TypenAme keyword tells the compiler to explain a special name into a type, and must use the TypenAme keyword to a NAME in the following cases: 1. A unique name (can be understood as a type of understanding), it is nested in another type. 2. Depending on a template parameter, it is said that template parameters contain this Name to some extent. When the template parameter makes the compiler have misunderstand when a type is recognized.
During insurance, you should use TypeName as a variable in all compilers. Just like the T :: ID in the example above, because we use Typename, so the compiler knows that it is a type, which can be used to declare and create an instance.
Give you a concise usage guide: If your type is limited in the template parameter, you must use Typename.
#include
After detailing the use of Typename, we can now select TypenAme to replace the Class declaration, which can increase the clarity of the program. //: c03: usingtypename.cpp
// using 'Typename' in The Template Argument List
Template
int main ()
{
X
} ///: ~
You will of course see that many similar code do not use the TypenAme keyword, because the template concept has been born for a long time, there is a TypenAme keyword.
Customize a type with Typename
To know the TypeName keyword not automatically type, TypeName SEQ :: Iterator it;
Just declares a variable of a SEQ :: Iterator type, if you want to define a new type, you have this: typedef typeename seq :: itemarator it;