What is Difference Between Struct And Class In C?
In C++, both structs and classes are used for creating user-defined data types, but they differ primarily in default access specifiers. In structs, members are public by default, while in classes, they are private by default. Additionally, structs are often used for passive data structures, while classes support encapsulation and behavior via methods. C, however, only supports structs, which can hold data but lack methods and access control features inherent in classes from C++.