1. Classes are usually used for large amounts of data, whereas structs are usually used for smaller amounts of data.
2. Classes can be inherited whereas structures not.
3. A structure couldn't have a destructor such as a class.
4. A structure can't be abstract, a class can.
5. A structure must always have the default parameter less constructor defined as public but a class might have one, so you can't define a private parameter-less constructor as in the following:
6. Class is a reference type and its object is created on the heap memory, whereas structure is a value type that is why its object is created on the stack memory.
7. Class can inherit another class, whereas structure does not support the inheritance.
8. Class object cannot be created without using the new keyword; it means we have to use it. Demo obj=new Demo();
whereas structure object can be created without using the new keyword.(optional) Demo obj;
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
1. Classes are usually used for large amounts of data, whereas structs are usually used for smaller amounts of data.
2. Classes can be inherited whereas structures not.
3. A structure couldn't have a destructor such as a class.
4. A structure can't be abstract, a class can.
5. A structure must always have the default parameter less constructor defined as public but a class might have one, so you can't define a private parameter-less constructor as in the following:
6. Class is a reference type and its object is created on the heap memory, whereas structure is a value type that is why its object is created on the stack memory.
7. Class can inherit another class, whereas structure does not support the inheritance.
8. Class object cannot be created without using the new keyword; it means we have to use it. Demo obj=new Demo();
whereas structure object can be created without using the new keyword.(optional) Demo obj;