Possible Duplicate:
What are the differences between struct and class in C++
I’ve done my homework and had diverse answers on Google.
Some say structs do not have inheritance, some say structs do not have access specifiers, while others say they have both.
Could someone clarify then, the differences between a struct and a class in C and C++, and also the difference between a struct in C & C++.
In C++, the only difference between a struct and a class is that struct members are public by default, and class members are private by default.
However, as a matter of style, it’s best to use the
structkeyword for something that could reasonably be a struct in C (more or less POD types), and theclasskeyword if it uses C++-specific features such as inheritance and member functions.C does not have classes.
C structs cannot use C++-specific features.
EDIT:
The C++ FAQ Lite, question 7.9, has this to say:
And quoting Stroustrup’s “The C++ Programming Language”, 4th edition, section 16.2.4: