typedef
typedef is used to create a type alias for an existing data type.
No new data type is created
Only an alternate name is given
typedef common usage
Simplifying Complex Types
typedefwith Pointers (Important)
typedefwith Arrays
typedefwith Structs
typedefwith function pointers
Type checking is not stricter
typedef works at compile time:
It’s resolved by the compiler. No runtime cost.
using
usingcreates a type alias.Makes complex types and templates much more readable.
using common usage
usingwith Pointers
usingwith Arrays
usingwith function pointers
usingwith Templates (most important)
typedefcan’t directly create template aliasesusingcan, which is why it’s preferred in modern C++
Type checking is not stricter
using works at compile time
The alias is resolved by the compiler. No extra runtime overhead.