
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
What is typedef declarations in C++?
The typedef keyword in C++ can be used to give a type a new name. For example, you can give a new name of BYTE to unsigned characters −
typedef unsigned char BYTE;
After this type definition, the identifier BYTE can be used as an abbreviation for the type unsigned char, for example −
BYTE b1, b2;
This will declare 2 variables b1 and b2 of type unsigned char. Typedefs are really useful when you have huge names due to namespaces, class names, etc. For example, if you want a variable of type std::vector<std::pair<int, int>>::iterator multiple times throughout your program. You can just rename it using typedef −
typedef std::vector<std::pair<int, int>>::iterator it_vec_pair;
And use it like −
it_vec_pair it;
- Related Articles
- What are forward declarations in C++?
- Array Declarations in C#
- What are Declarations?
- Explain structures using typedef keyword in C language
- Typedef in Dart Programming
- What are JSP declarations? In how many ways we can write JSP declarations?
- C# Multiple Local Variable Declarations
- What is the difference between Definitions and Declarations in Compiler design?
- Difference between 'struct' and 'typedef struct' in C++?
- Array Declarations in Java
- Difference between 'struct' and 'typedef struct' in C++ program?
- Use Declarations in Rust Programming
- Group Use declarations in PHP 7
- What are the rules for external declarations in JShell in Java 9?
- Do we need forward declarations in Java?

Advertisements