Struct versus class?
C++11 offers compile-time checking for exactly this problem though (for example in a static assert). For serializability (excluding padding-related problems) std::is_trivially_copyable is the perfect fit. The whole std::is_pod constraint is an unnecessarily strong requirement for just serialization issues.
Maybe a bit off topic, but I don't have a clue what you mean in the last reply.
Can you explain it a bit more 'dummy', serializable constructs, convention, serializability, padding, serialization issues
Serializable (in this context) means you can just write the struct directly to disk with fwrite in binary mode and read it back in with fread,
Structs are usually padded so if you have a 16bit short followed by a 32bit int directly after each other the 32bit int normally has an address 4 bytes after the address of the 16bit short.
A convention is a place where people put on bad costumes and try and meet actors from Star Trek.
oh not this again, been answering this question since forever lol.
The only difference is in struct by default(in absence of access modifier) all members are public and where as in class they are private that makes class a better candidate for implementing abstraction in genera,l however with explicit access modifier inside a struct makes it same thing as class in every which way.
Any other difference one can rightly think of is either derived from or result of above ^.
oh not this again, been answering this question since forever lol.
The only difference is in struct by default(in absence of access modifier) all members are private and where as in class they are public that makes class a better candidate for implementing abstraction in genera,l however with explicit access modifier inside a struct makes it same thing as class in every which way.
Any other difference one can rightly think of is either derived from or result of above ^.
Aside from the fact that you got your default access specifies wrong; class is private and struct is public and not the other way around, this thread was created to ask the question where people draw the line between when to use a class and when to use a struct. Some people use class or struct for everything, some people use structs for storage types only, and so on. So no, this is not your typical struct vs. class question.
The fact that 10 people in this thread have provided 20 different answers makes it clear that the line to draw is fuzzy. It's simply a matter of personal preference. Frob's reasoning in the second post in this thread makes the most sense to me,
. So no, this is not your typical struct vs. class question.
Oight Brother Bob, answered too hastily.