What is difference between Structure and class?


Class

  • It is reference type.
  • Null value can be assigned to a variable in a class.
  • It can have destructor.
  • All variables in classes are by default private.
  • Good to be used from architecture view as it provides high flexibility.

Structure

  • It is value type.
  • Null value assignment is not feasible here.
  • Cannot have destructor.
  • All variables in structures are public.
  • Good to be used for simple data structures.