Possible duplicate:
What are the differences between structure and class in C ++
I used to think that the only differences between C ++ classes were the default class, access modifiers for the member, and the guarantee of the folded type.
It turns out I was wrong because this code does not compile:
class { int value; } var = { 42 };
then how it does:
struct { int value; } var = { 42 };
I can't understand why there is a difference, but apparently in Visual C ++ 2008:
error C2552: 'var' : non-aggregates cannot be initialized using the list of initializers
So yes, I will ask a duplicate duplicate question (I hope without duplicate answers!):
What are all the differences between C ++ structures and classes?
Of course, feel free to close this if you discover that I missed something on other issues - of course I could. But I did not see this being discussed in any of the answers, so I thought I'd ask.
source share