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.
Discussion:
23 comments Page 2 of 3.
Shivam said:
10 years ago
In that case if we pass any parameter in the default constructor that can not be acceptable in the constructor.
Alok raj said:
1 decade ago
Default constructor uses default values if it is required. The sense of "if it is required" is in this sense guys if less argument is given then required then only it is used.
So if no argument is given that it will use default values. Thus default constructor.
So if no argument is given that it will use default values. Thus default constructor.
Sharmila said:
1 decade ago
Why it does no take parameter?
Premchandar777 said:
1 decade ago
The term default in the sense, it takes common value (default) when its not assigned.
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.
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.
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();
}
#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();
}
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.
Yog patil said:
1 decade ago
Default constructor does not take any argument. its syntax is given as:
sample( )
{
x=0;
y=0;
}
sample( )
{
x=0;
y=0;
}
Vijayakumar said:
1 decade ago
If it takes parameter it is not default constructor.
Animesh said:
1 decade ago
If you supply a constructor with parameters then a default will not be created.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers