Struct vs Typedef Struct in C++ Last Updated : 06 Oct, 2025 Comments Improve Suggest changes Like Article Like Report In C++, the struct keyword is used to define a struct, whereas the typedef keyword is used for creating an alias(new name) for existing datatypes or a user-defined datatypes like class, struct, and union to give them more meaningful names. In C, programmers often write typedef struct { ... } Alias; to avoid repeating the keyword struct.In C++, this is not required. The struct name itself is already a type alias.struct in C++ The struct keyword defines a user-defined data type that groups variables under a single name. In C++, once a struct is declared, its name can be used directly as a type without needing typedef.Here is an example of struct. C++ #include <iostream> using namespace std; // define a struct MyStruct struct MyStruct { int num; void increase() { num += 5; } }; int main() { MyStruct obj; obj.num = 5; obj.increase(); cout << "Number is: " << obj.num << endl; return 0; } OutputNumber is: 10 typedef struct in C++Here is an example of typedef with struct. Please note that most of the time, we do not need typedef with struct. Here we have shown example to show that it is syntactically correct to use typedef. C++ #include <iostream> using namespace std; typedef struct MyStruct { int num; void increase() { num += 5; } } MyStruct; int main() { MyStruct obj; obj.num = 5; obj.increase(); cout << "Number is: " << obj.num << endl; return 0; } OutputNumber is: 10 Difference Between Struct and Typedef Struct in C++struct defines a user-defined composite type; typedef struct defines a struct and simultaneously creates an alias for it.struct objects can be declared directly using the struct name; typedef struct objects can be declared using the alias without writing struct.struct groups variables (and functions) under one type; typedef struct also provides a convenient alternative name for the type.struct name itself acts as a type; typedef struct provides an explicit alias for the type.struct is used directly; typedef struct can be replaced with using for clearer modern C++ type aliases. Create Quiz Comment M memegubu0c Follow 0 Improve M memegubu0c Follow 0 Improve Article Tags : C++ Programs C++ cpp-struct CPP Examples Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like