Posts

Showing posts with the label constructor

Constructor in C++

Constructor:                 Constructor is a special type of member function that is automatically called when an object of the class is created to whom the constructor belongs. Properties of constructor: A constructor initializes an object as soon as it is created. Constructor name is same as class name and it doesn't have a return type.       class A         {        public:               A ( )    // constructor of class A                 {                   // object initialization                  }         }; Constructors can be defined either inside the class definition or outside class definition using class name and scope resolution ::  operator. Uses of constructor: Constructor ...