Wednesday, October 2, 2019

Difference between Struct and Class


Struct Class
The Struct is a value type. Class is a reference type.
Struct is usually for small amount of data. Class is usually for large amount of data.
Struct type are used in stack memory. Class type are used in heap memory.
Struct can't be inherited from other type. Class can be inherited from other type.
Struct can't be abstract. Class can be abstract.
No need to create object by new keyword. We can't use the object of a class by using new keyword.
Don't have any default constructor or destructor. We can create a default constructor or destructor.
Struct can't be the protected data member. Class can be the protected data member.

No comments:

Post a Comment