- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is typedef declarations in C++?
45 Lectures 4.5 hours
66 Lectures 5.5 hours
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 −
- What are Declarations?
- Typedef in Dart Programming
- What are forward declarations in C++?
- What are JSP declarations? In how many ways we can write JSP declarations?
- What is the difference between Definitions and Declarations in Compiler design?
- Array Declarations in Java
- Array Declarations in C#
- Use Declarations in Rust Programming
- Explain structures using typedef keyword in C language
- Group Use declarations in PHP 7
- C# Multiple Local Variable Declarations
- MySQL row declarations for ZF?
- Understanding CSS Selector and Declarations
- What are the rules for external declarations in JShell in Java 9?
- Do we need forward declarations in Java?