why all c++ program must have default constructor?

Answer Posted / rahin99435

The purpose of constructor is to initialize the class members and allocate necessary resources for them; at runtime.So by default C++ compiler is provided with a default constructor which performs the same job at runtime while the object is created.
There is provision of defining more than one constructor by changing the signatures to get objects of different kind.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you show the declaration of a virtual constructor?

612


Can a new be used in place of old mallocq? If yes, why?

719


Suppose that data is an array of 1000 integers. Write a single function call that will sort the 100 elements data [222] through data [321].

1075


How come you find out if a linked-list is a cycle or not?

658


Keyword mean in declaration?

678






What is c++ prototype?

682


Which software is best for programming?

752


Is it possible to provide default values while overloading a binary operator?

871


What is the difference between map and hashmap in c++?

663


Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;

1593


What is the difference between cin.read() and cin.getline()?

655


We all know that a const variable needs to be initialized at the time of declaration. Then how come the program given below runs properly even when we have not initialized p?

694


If dog is a friend of boy, and terrier derives from dog, is terrier a friend of boy?

708


Describe the setting up of my member functions to avoid overriding by the derived class?

700


What is virtual base class uses?

817