Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) typedef

 

typedef is a keyword to define shorthand names for data types.

 

typedef std::vector<int>::const_iterator Iterator;

 

Avoid typedefs at file scope in header files [1]. When using function pointers, consider always using a typedef [2].

 

 

 

 

 

Advice

 

 

 

 

 

 

References

 

  1. John Lakos. Large-Scale C++ Software Design. 1996. ISBN: 0-201-63362-0. Chapter 2.3.3
  2. Joint Strike Fighter Air Vehicle C++ Coding Standards for the System Development and Demonstration Program. Document Number 2RDU00001 Rev C. December 2005. AV Rule 176: 'A typedef will be used to simplify program syntax when declaring function pointers.'
  3. Trevor Misfeldt, Gregory Bumgardner, Andrew Gray. The elements of C++ style. 2004. ISBN: 978-0-521-89308-4. Chapter 4.2, page 18: 'Use UpperCamelCase for classes, constants, structures, enumerations, and typedefs'
  4. C++ Core Guidelines item T.43: 'Prefer using over typedef for defining aliases'

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict