Difference between 'struct' and 'typedef struct' in C++?


In C++, there is no difference between 'struct' and 'typedef struct' because, in C++, all struct/union/enum/class declarations act like they are implicitly typedef'ed, as long as the name is not hidden by another declaration with the same name.

Though there is one subtle difference that typedefs cannot be forward declared. So for the typedef option, you must include the file containing the typedef before it is used anywhere.


Updated on: 30-Jul-2019

732 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements