C++ Structs - Pointless?
c, c++
Solution
Classes and structures in C++ are almost the same, the only things that separates them is that the default visibility of a class is `private` while in a struct it's `public`.
The reason to keep having structures in C++ was probably to keep the language compatible with C, so it would be easier to port C code to C++, or for programmers to make that transition.
As for the usage of structures contra classes, I personally use them just like would in C, to group related variables together in a single "object".
Problem
Possible Duplicate: What are the differences between struct and class in C++ I'm just trying to figure out if using 'C structs' in C++ are essentially useless or not. Do you gain anything by using them (opposed to simply creating another class)? In C the point of structs is obvious, simply contiguous allocations of grouped data and a nice way to access said data, in C++ I feel the role becomes a little more vague. Seeing as that you can have functions which are members of structs, instance variables, and visibility labels, the only real difference that I see between structs and classes in C++ is that struct members default to public while class members default to private. The way I see them, they can actually both be implemented with the same exact underlying system. So am I missing something here as to the purpose of structs in C++? Or have they kind of lost their purpose, as I feel they have in C++?