+ 2
What is the difference between class and struct?
2 Réponses
+ 6
classes allow you to group methods together
struct is like a primitive structure which groups attribute together
some languages provide struct but no class some both
you use them according to need
e.g. going for classes for something simple is not it see struct
+ 2
Classes support methods, although I've seen structures with methods in C#, in general structures are just records that contain fields.
Class methods provides support for per field input validation and read-only fields. Multiple instances and internal data initialization is easy with class (by using constructors), where structures may need careful measures.