C++ Programming - Constructors and Destructors - Discussion

Discussion Forum : Constructors and Destructors - General Questions (Q.No. 1)
1.
A constructor that accepts __________ parameters is called the default constructor.
one
two
no
three
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
23 comments Page 1 of 3.

Sharmila said:   1 decade ago
Why it does no take parameter?

Anuradha K said:   1 decade ago
Constructor with no parameters or any number of parameters with default values is called default constructor.

constrctr()
or
constrctr( int a = 1, int b = 2 )

Himanshu dixit said:   1 decade ago
Compiler itself call constructor if no constructor is called with no parameter. Or if user provide constructor with zero parameter then compiler takes it.

Sathish said:   1 decade ago
Why does not using of parameters ?

Animesh said:   1 decade ago
If you supply a constructor with parameters then a default will not be created.

Vijayakumar said:   1 decade ago
If it takes parameter it is not default constructor.

Yog patil said:   1 decade ago
Default constructor does not take any argument. its syntax is given as:

sample( )
{
x=0;
y=0;
}

Goral patel said:   1 decade ago
Default constructor we simply means that it has no argument. In this way we pass some argument then it is not default. But when this arguments with default values is called default cons.

Rohan said:   1 decade ago
It does not take any arguments or parameters.

#include<iostream.h>
#include<conio.h>
class integer
{
private: //optional
int m,n;
public:
integer() //default consturctor
{
m=0;
n=0;
}
};
void mian()
{
integer i1; //object created
getch();
}

Sabyasachi lenka said:   1 decade ago
If there is any argument type constructor is present, then,

We have to declare constructor function for each and every class type objects passing argument.

In other case if object doesn't pass any value then compiler itself automatically construct a no argument type default constructor.

That's all.


Post your comments here:

Your comments will be displayed after verification.