SUMMARY
  • Constructor is a special method, used to initialize an object at the time of declaration. This Method has the same name as that of the class.
  • The constructor enables an object to initialize itself when it is created. This is known as automatic initialization.
  • When we define a class without any constructor, the system (compiler) supplies a constructor. It is called system supplied constructor.
  • Do-nothing constructor is another term for system supplied constructor because such constructors do nothing!
  • Constructors do not have return type declarations (even a void is not allowed).
  • You cannot take addresses of constructors and destructors.
  • Constructors in a class can be private (syntactically). However, it should always be declared as public. ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.