struct vs class

can anyone tell me the difference between a struct and a class? they seem very similar to me. also what are the benefits of using one over the other? i usually use classes but will use structs more if i know how it useful for me.
The only difference between a class and a struct is the default access modifier.
Check this out -> http://www.cplusplus.com/forum/beginner/21863/
Last edited on
I personally use a struct when I know all members would be public. But you can use a class always anyway.
Struct is from C. C++ has it to be compatible with C but in C++ behaves almost the same as a class
i see....not really a big diff huh, thanks alot guys. but is one more efficient than the other? like is more memory allocated to make a class than a struct? or is the only diff really the default access modifier?
The only difference is the default access of members / inheritance
closed account (S6k9GNh0)
Seriously, in the definition of the C++ language, that is exactly what it says. One is no more efficient than the other at any time or place.
Topic archived. No new replies allowed.