What is the effect of marking a single-argument constructor explicit?
Correct answer B. It cannot be used for implicit conversions or copy-initialisation
Without explicit, a constructor such as Buffer(int size) also acts as an implicit conversion, so Buffer b = 10; or passing 10 to a function expecting Buffer silently creates an object. explicit blocks these implicit conversions while still allowing direct initialisation like Buffer b(10). Marking single-argument constructors explicit prevents surprising conversions and bugs.
Answer checked How we write and check questions
Discussion