A struct is defined in C, and the typedef is usually used to alias the struct, for example:
1 struct Tagobject 2 {3 int weight; 4 int Price ; 5 int status; 6 }object;
Thus, when a variable is created with this custom data structure, it can be written like this:
1 OBJECT objs;
And if it is not redefined with TypeDef, that is, by the original definition of the struct:
1 struct Tagobject 2 {3 int weight; 4 int Price ; 5 int status; 6 }object;
Thus, if you want to create a variable of this type, you need to define this:
1 struct tagobject objs;
The essential reason is that the data type created is a struct tagobject, not a tagobject.
However, in C + + there is no need to define a TypeDef, struct and class The only difference is the default access level , which class is private and struct public .
The difference between C and C + + struct