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

Discussion Forum : Object Oriented Programming Using C++ - Section 1 (Q.No. 11)
11.
When the compiler cannot differentiate between two overloaded constructors, they are called
overloaded
destructed
ambiguous
dubious
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
2 comments Page 1 of 1.

Xoxo said:   1 decade ago
^to the one who can't google this.

The problem exists when you try to instantiate a class that could apply to more than one constructor.

For example:

public Example(String name) {
this.name = name;
}

public Example(SomeOther other) {
this.other = other;
}

If you call the constructor with a String object, there's one definite constructor. However, if you instantiate new Example(null) then it could apply to either and is therefore ambiguous.

The same can apply to methods with similar signatures.

Harpreet said:   1 decade ago
Please give some examples.

Post your comments here:

Your comments will be displayed after verification.