Question:
class A() { };
int main() { A a; }
Whether there will be a default constructor provided by the compiler in above case ?
Answer:
yes, if the designer of the class donot define any constructor in the class. then the compiler provides the default constructor in the class. Source: CoolInterview.com
I have a doubt, is it possible without declare any members to that class? if happen, explain how? Source: CoolInterview.com
Answered by: madhav | Date:
| Contact madhav
NO! The class declared is a POD-Struct. These structures are represented only as passive collections of field values, without using encapsulation or any other object-oriented features! This means that there is no Constructor or Destructor to this class.
Source: CoolInterview.com
Answered by: Doron Moraz | Date: 11/12/2007
| Contact Doron Moraz
Yes... it provide default constructor. When you create object or A & press ( , that time it gives parameter "const &a". Source: CoolInterview.com
Answered by: Prashant | Date: 8/4/2008
| Contact Prashant
A default constructor will be added by the compiler for any class where user does not supply any constructor.
I have never heard abt POD or nething like that. Can you please explain what you r trying to describe here Source: CoolInterview.com
Answered by: Dunni | Date: 6/20/2009
| Contact Dunni
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.
|