Tips: C++ Constructor

  • If you are not declared any constructor in a class, then the compiler assumes the class to have a default constructor. This is called implicit default contructor. This  constructor will not take any arguments.
  • Like any other function, constructor can also be overload with more then one parameters or different type of parameters. constructors are automatically called, the one whose parameters match the arguments passed on the object.
  • But if you declare your own constructor for a class, the compiler no longer provides an implicit default constructor.
  • Generally if you create a class, by default the compiler will create four special member functions for you. that is:
    • Implicit constructor
    • Copy constructor
    • Assignment operator
    • Destructor
          This will remain until you declare your own.