Question:
In c++ have a default constructor ?
Answer:
Yes C++ does have a default constructor provided by the compiler.In this case all the members of the class are initialized to null values.These values act as the default values.For eg: MyClass me;In the above case since the object is not initialized to any value so the default constructor will be called which will initialize the class with the default values. Source: CoolInterview.com
Above answer is right, but remember If you write down one or more parametric constructor then If u want to create a object without any parameter then at that time compiler doesn't create the empty constructor, you must write down your own empty constructor. Source: CoolInterview.com
Answered by: deepen mehta | Date:
| Contact deepen mehta
Above answer is right, but remember If you write down one or more parametric constructor then If u want to create a object without any parameter then at that time compiler doesn't create the empty constructor, you must write down your own empty constructor. Source: CoolInterview.com
Answered by: Nagasivakrishna | Date:
| Contact Nagasivakrishna
yes..The point is, compiler by default creates the default constructor only and only if the class doesn't contain any constructor. Source: CoolInterview.com
Answered by: Sawan | Date: 4/8/2010
| Contact Sawan
Yes,it has the default constructor
Regards, Nicku Source: CoolInterview.com
Answered by: nicku | Date: 8/16/2010
| Contact nicku
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|