C++ Programming - Constructors and Destructors - Discussion

Discussion Forum : Constructors and Destructors - General Questions (Q.No. 23)
23.
A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.
default constructor
copy constructor
Both A and B
None of these
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
2 comments Page 1 of 1.

Ankur Mittal said:   1 decade ago
Copy Constructor alway required a reference of the same object. So if it is not having any parameter then it cant be copy constructor.

If my constructor having all the parameter as default then at the time of object creation no need to pass any parameter and it will call that constructor only.

For Exp:
Class A
{
private:
int x;
public:
A(int val = 5)
{
x=val;
}
};

In the above example if we create A a; then it will set x's value 5 only.

Cherr said:   1 decade ago
Default constructors and default argument constructors both are different.

Post your comments here:

Your comments will be displayed after verification.