Introduction to Programming Cs201: GDB Solution



        Comparison between Struct and Class:

  • Struct and class are user defied data types
  • By default struct is a public where as class is private
  • Class implements the principal of encapsulation
  • Objects of a class are created on the heap memory
  • Class is used for re usability where as structure is used for grouping the data in the same structure
  • Struct data members cannot be initialised directly but they can be assigned by the outside the structure
  • Class data members can be initialised directly by the parameter less constructor and assigned by the parameterised constructor.
     Please comment,like and share

regards, 

Hafiz Muhammad Umar Hayat




Comments