When to use structures in c++?

Hi,

Can can any body tell explain me when to go for structures and when to go for classes in c++.
Since both supports access spcifies,member fnctions and inheritance.

Thanks
Last edited on
structures are mostly C compatibility things. They are absolute equivalent for classes aside from default access specifiers.

Usually you would use struct for aggregate classes which have only public methods/members.
The Google C++ style guide is generally very bad and should not be used unless you work at Google.

Cubbi completely ripped it apart point-by-point before. Let me see if I can find the link...

EDIT: here it is:

https://www.linkedin.com/today/post/article/20140503193653-3046051-why-google-style-guide-for-c-is-a-deal-breaker
Last edited on
That first comment, ironically by someone who works for Google, really shows how defensive they are over their style guide. As for the question, I'd honestly just use structures for things that are strictly variable holders that may or may not overload functions, though that's just for my own mental ease. I mean, it's easier for me to differentiate classes that hold several variables and classes with several functions and variables if I split the two. Functionality is the same, but it's less thinking while coding over things that are unnecessary to worry about.
That first comment
That comment wasn't here when I read it the first time.
REQUIREMENT OF THE C++ SPECIFICATION part made me chuckle.
Topic archived. No new replies allowed.