Classes and Objects

Classes :

  • Classes define the characteristics and behaviour of an object.
  • A class is a blueprint for an object.
  • It is a logical entity.

Objects :

  • Any real world entity is called an object.
  • An object has characteristics and behavior.
  • Object is an instance of a class or the implementation of a class.
The syntax for defining class is:
class class_name
     {
      ……//Data members and functions//…..
     }
Any class has generally these constituents :

  • Data members
  • Member functions
  • Constructors and destructors
Data members : Data members are the data items of different data types that are used by objects
Member functions :
  • Member functions are the functions that are declared inside a class.
  • They can access every data member or member function of a class.
  • They can be defined within or outside the class.
  • If they are defined outside, scope resolution operator (::) is used
    Syntax :
    return_type class_name::func_name(…parameters) 
            {
            ……. 
            }
  • When they are defined within class, they are, by default, inline.

Leave a Reply

Your email address will not be published. Required fields are marked *