Q:

Explain whether the Sales_data constructor that takes a string should be explicit. What are the benefits of making the constructor explicit? What are the drawbacks

0

Explain whether the Sales_data constructor that takes a string should be explicit. What are the benefits of making the constructor explicit? What are the drawbacks?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

It should be `explicit`. Otherwise, code like `item.combine("9-999-99999-9")` will compile, but the code has no logical meaning.

Making the constructor `explicit` will stop compiler from automatically converting one type to the class type, which makes the code same as anticipation.

The drawback is we must call the constructor explicitly if we want to cover one type to the class type.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now