Computer Science - Object Oriented Programming Using C++ - Discussion

Discussion Forum : Object Oriented Programming Using C++ - Section 2 (Q.No. 29)
29.
If you want to override constructor default values for an object you are instantiating, you must also override
all other parameters to that constructor
all parameters to the left of that value
all parameters to the right of that value
no other parameters to that constructor
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Jasminder singh said:   1 year ago
The default paramters are ser like this in any function in c++.
class Demo{
// constructor.
Demo(int a, int b = 0, int c = 0) {
// code here.
}
};

If we want to override the default parameters of the constructor we need also override or pass the argument to the left values for example look below.
Demo obj = new Demo(1,2,3);
we also set the first parameter of the constructor otherwise it will throw an exception or error.

Riddhi said:   5 years ago
Please explain the answer.

Meenakshi said:   1 decade ago
Please explain this answer?

Aman said:   1 decade ago
Please explain this answer in detail.

Post your comments here:

Your comments will be displayed after verification.