Typedef declaration

From Cppreference

Jump to: navigation, search

The typedef declaration provides a way to use an identifier in place of a (possibly complex) type declaration to create new objects of that type.

Contents

[edit] Syntax

typedef type_declaration identifier;

[edit] Explanation

[edit] Keywords

typedef

[edit] Example

typedef char** string_array;  // Allows us to write
string_array c;  // instead of
char **c;


Similarly,

typedef void *(*my_function)(int, char, double);

would allow my_function to be used to create a pointer to a function that takes an int, a char, and a double and returns a void pointer.