GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 107 of 203    Print  
Under which conditions compiler provide default constructor to an object when no default constructor is defined in the class definition?

  
Total Answers and Comments: 4 Last Update: December 07, 2008     Asked by: Ashish 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Prasad2008
 
If the class designer has not provided any constructor within the class, but we are trying to create an object of that class without passing any argument , then compiler will provide a default zero argument constructor. But in the same scenario, if we are creating an object and trying to pass argument(s) to the object at the time of its creation, in that case compiler will not provide any  one-argument, two-argument constructors etc. It will throw an error.

Above answer was rated as good by the following members:
yzesong
January 09, 2007 08:50:08   #1  
       

RE: Under which conditions compiler provide default co...
Only if the class has no constants and references ( have to initialized upon creation)

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
February 08, 2007 22:49:55   #2  
MA        

RE: Under which conditions compiler provide default co...
also when you create a consturctor with arguments it has to call defaul no argument consturctor :).
 
Is this answer useful? Yes | No
June 10, 2008 11:12:23   #3  
Prasad2008 Member Since: June 2008   Contribution: 8    

RE: Under which conditions compiler provide default constructor to an object when no default constructor is defined in the class definition?
If the class designer has not provided any constructor within the class but we are trying to create an object of that class without passing any argument then compiler will provide a default zero argument constructor. But in the same scenario if we are creating an object and trying to pass argument(s) to the object at the time of its creation in that case compiler will not provide any one-argument two-argument constructors etc. It will throw an error.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
December 07, 2008 10:29:53   #4  
burraganesh Member Since: December 2008   Contribution: 20    

RE: Under which conditions compiler provide default constructor to an object when no default constructor is defined in the class definition?
Unconditional
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape