why all c++ program must have default constructor?

Answer Posted / sourisengupta

When you create a Object with no arguments, the compiler automatically creates a default constructor internally. But when you use parameterized constructor in your code then you need to provide the default constructor in your code so that the compiler does not throw any errors at compile time.

It also depends on compiler. some compiler also supports this feature. then you do not need to write default constructor in the code.

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define upcasting.

793


What is a container class? What are the types of container classes in c++?

873


What does new return if there is insufficient memory to make your new object?

782


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

2291


Will the following program execute?

785


Give 10 points of differences between C & C++.

846


Describe new operator?

841


Can we use struct in c++?

773


Does c++ have foreach?

735


What is a hash function c++?

765


What is the real purpose of class – to export data?

840


Can I uninstall microsoft c++ redistributable?

782


what is pre-processor in C++?

801


Describe linkages and types of linkages?

769


Write syntax to define friend functions in C++.

810