What is constructor and why it is used in C++?

A constructor in C++ is a special ‘MEMBER FUNCTION’ having the same name as that of its class which is used to initialize some valid values to the data members of an object . It is executed automatically whenever an object of a class is created.

Sizin İçin Seçtik  What is a default constructor How is an object's instance variables initialized if a class has only a default constructor?

Leave a Reply

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