Ask Question
10 February, 09:01

What is the purpose of a constructor?

Answers (1)
  1. 10 February, 10:57
    The main purpose of the constructor in the computer science is to initialize the object of the class. The constructor is basically called after the allocation of the memory in the object. When the object is created, the constructor are basically used to initialize as default value.

    Constructor is also known as special type of the member function. The compiler called the constructor whenever the object has been create and the construction has similar name of the given class.


    Class test () {

    int p, r; / / variable declaration


    / / constructor

    / / Assigning value in the constructor



    Cout<<" Constructor value/n";

Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What is the purpose of a constructor? ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers