+ 2

What is the difference between class and struct?

2nd Jul 2017, 5:36 AM
Prajakta Dilip Jadhav
2 odpowiedzi
+ 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
2nd Jul 2017, 5:39 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 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.
6th Jul 2017, 4:17 AM
Ipang