1.

Which constructor definition will produce a compile time error?(a) className(int x=0);(b) className(char c);(c) className(int x=0,char c);(d) className(char c,int x=0);I have been asked this question by my college director while I was bunking the class.Enquiry is from Constructors Overloading in chapter Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer»

Correct answer is (c) className(INT x=0,char c);

To EXPLAIN: The default ARGUMENTS, just like with member functions, must be listed at last in the ARGUMENT list. Hence this will produce a COMPILE time error. The compiler doesn’t allow the definition to be executed.



Discussion

No Comment Found

Related InterviewSolutions