C + + retains the struct of the language and expands it. In the C language, a struct can contain only data members and cannot contain member functions . In C + +, astruct is similar to class, and can contain both a data member and a member function.
In C + +, structs and classes are basically generic, except that if you use the Class keyword, the member variable or member function defined in the class is the private property by default, and the struct keyword is used. A member variable or member function defined in a struct is the public property by default.
In C + +, the C language of the struct keyword is not discarded, its significance lies in the C language Program developers have a sense of belonging, and can make the C + + compiler compatible with the previous development of the C language project.
The difference between C + + classes and struct structs