Classes and Objects in C++

  Classes and Objects in C++

Class

  • Class is a user defined data type
  • Class has both data members and member functions that work on those data members
  • A class is a collection of objects of similar type
  • Class allows the data (and functions) to be hidden, if necessary, from external use
  • Data hiding is done through access modifiers
  • By default, data members are ‘private’ (mode of visibility/access modifier)
  • Class provides a blueprint for object creation
  • Once a class has been defined, we can create any number of objects belonging to that class

Object

  • Objects are basic run-time entities of an object oriented system
  • Program objects must be chosen such that they match closely with real world objects
  • An object is a instance of a class
  • In simple terms, objects are variable of type class