Quote:
Originally Posted by zlatnik
There is a difference that neither person who posted so far mentioned- all members of a struct are public by default, and all members of a class are private by default. Right now I'm trying to decide when it is appropriate to use a struct in my code (I'm strictly a C++ programmer)- I guess I am not convinced it is ever a good idea, at least with objects that are written to and read from disk. I'm still undecided for certain though.
|
members of a struct are public by default and members of a class are private by default!
However a struct can have private members using
there is no other difference!
As somebody pointed out, in C# structs are significantly different than classes!
Here is a stupid interview question I got once:
"is a class a struct?" answer is yes and no