Friday, 18 March 2016

Diffenrence between class and structure


 (1) A class is a reference type whereas a structure is a value type.
 (2)While creating an object for a Class , CLR allocates memory for object in Heap ,  whereas while creating an instance of Structure ,    CLR creates memory in Stack.
  (3) Classes support  Inheritance whereas Structure do not support Inheritance.
    (4)Variables of a Class can have a NULL values but variables of Structure can not have a NULL value.
    (5)Class can contain Constructor and Destructor when initialized an object where as Structure members initialized automatically without Constructor.

No comments:

Post a Comment