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

What is c++ good for?

683


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


what is COPY CONSTRUCTOR and what is it used for?

712


What are c++ files?

683


What are function prototypes?

825






Is it possible to get the source code back from binary file?

838


Can a class be static in c++?

675


How did c++ get its name?

661


What is a class template?

695


Can we declare a base-class destructor as virtual?

660


In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h

811


What is the copy-and-swap idiom?

719


Which bit wise operator is suitable for checking whether a particular bit is on or off?

695


Can a program run without main in c++?

687


What is c++ hiding?

724