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

C++Server Side ProgrammingProgramming

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.

Published on 28-Feb-2018 14:47:08