![]() |
VOOZH | about |
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.
struct keyword defines a user-defined data type that groups variables under a single name. Here is an example of struct.
Number is: 10
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.
Number is: 10