Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

In C++, when would you use a struct over a class?

OpenStudy (anonymous):

when i can't be bothered with "public:", which is always

OpenStudy (shadowfiend):

Heh. A pretty fair point. You should watch out though. More than in many languages, public is dangerous in C++ if you're writing a library. All public interfaces are fragile in C++ because changing any of a number of tiny details will make them binary incompatible with previous versions. Also see things like the d-ptr pattern used by the Qt toolkit to avoid this as much as possible -> http://en.wikipedia.org/wiki/Opaque_pointer#C.2B.2B . Other than that, yeah, there's no real reason to use structs. Literally the only difference is that they have public members by default, rather than private.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!