Pages

Tuesday, October 18, 2011

Difference between Structure a class and its use.

The basic difference between a structure and a class is that a class is a reference type while a structure is not.All the information regarding different properties and functionality of an of an object are contained in the structure it self. Though Classes have an edge over structures as they belong to the Oops family structures are much handy in cases where there are limited range of values for a particular entity For example color of car and its model....etc...Structures are handy where we require less space comparatively Structures can include constructors but these must include parameters Structures cannot inherit another structure but they can implement interfaces.... Classes use Heap method for storage to which further space can be allocated easily while Structures use stacks as a storage medium so their storage is not expandable that is why where memory constraint is a factor structures and Unions are preferred over classes

No comments:

Post a Comment