Dynamic Constructor in C++

Allocation of memory to objects at the time of their construction is known as dynamic constructors of objects. The memory is allocated with the help of new operator. The constructors can also be used to allocate memory while creating objects dynamically. This will enable the system to allocate the right amount of memory for each object when the objects are not of the same size, thus resulting in the saving of memory. Dynamic memory allocation is always refers the use of new operator. Dynamic memory allocation is directly connected with…

Read More

Constructor in C++

C++ provides a special member function called the constructor which enables an object to initialize itself when it is created. What is Constructor ? “A constructor is a special member function whose task is to initialize the objects of its class.” It is special because its name is the same name as the class name. The constructor is invoked whenever an object of its associated class is created. It is called constructor because it constructs the values of data members of the class. Syntax: A constructor is declared and defined…

Read More