Type Definition in C++

Typedef is used to create new names for types and structures. It can save the user some typing when using a structure or variable data type.

typedef oldTypeName newTypeName;


A typedef is typically used to give a structure its own type, instead of having to type out 'struct structName' every time.

typedef unsigned int u_int; //giving 'unsigned int' a name of u_int
//Now, doing this
u_int myNumber;
//Is the same as doing this (except with a different variable name of course)
unsigned int myNumber2;

See Also

Other data types - C++ Reference

Add to Slack

< Structures   |   Vectors >

© 2019 SyntaxDB. All Rights Reserved.