C++ Programming - Constructors and Destructors - Discussion
Discussion Forum : Constructors and Destructors - Programs (Q.No. 7)
7.
Which of the following constructor is used in the program given below?
#include<iostream.h>
class IndiaBix
{
int x, y;
public:
IndiaBix(int xx = 10, int yy = 20 )
{
x = xx;
y = yy;
}
void Display()
{
cout<< x << " " << y << endl;
}
~IndiaBix()
{ }
};
int main()
{
IndiaBix objBix;
objBix.Display();
return 0;
}
Discussion:
7 comments Page 1 of 1.
Satya said:
1 decade ago
The correct answer should be,
Either.
'Default argument constructor' or
'Constructor with default arguments' or
'Default parametrized constructor'
Instead of
'Default constructor'.
Default constructor seems to be pointing to the default constructor supplied by the compiler when we supply none. Please correct me if I'm wrong.
Either.
'Default argument constructor' or
'Constructor with default arguments' or
'Default parametrized constructor'
Instead of
'Default constructor'.
Default constructor seems to be pointing to the default constructor supplied by the compiler when we supply none. Please correct me if I'm wrong.
Bhairavi said:
8 years ago
Answer is 'Default Constructor' because object with no argument is created for class IndiaBix. And in IndiaBix class there is a constructor with default values means it is default constructor.
(1)
Priya said:
7 years ago
When we have already made a constructor by ourself. There would be no default constructor made by the compiler. The answer to this is wrong according to me.
Serg said:
7 years ago
The Constructor is the default if it generated by the compiler. We have own 'simple' one so no default generated at all. We call our simple one!
(1)
Ebin said:
1 decade ago
The no argument objects are created for the class IndiaBix. So It is considered as a Default argument Constructor.
Sarvesh karan said:
7 years ago
The compiler won't invoke own default constructor due to the presence of parameterized constructor.
Hari said:
7 years ago
I think the given answer is wrong because the parameters is there in given example.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers