As an βencodingβ style, this is most likely a C legacy where a keyword is needed.
In C ++, this is not required in most situations, although it is sometimes used to force the compiler to resolve the name of the type name and not the name of any other entity (for example, a variable, as in the following example):
struct x { }; int main() { int x = 42; struct x* pX = nullptr;
Personally, I donβt think that a good style has a variable or function with the same name as the type, and I prefer to avoid using the struct keyword for this purpose in general, but the language allows this.
source share