The example is from Chapter 7 in C++ Primer 5th
.
Suppose class Sales_data
has such constructor:
Sales_data(const std::string &s): bookNo(s) { }
And it has a public function member:
Sales_data &combine(Sales_data &s){...}
The flowing is error:(item
is a Sales_data
instance)
item.combine("9-999-9999");
The reason is that: Only One Class-Type Conversion Is Allowed, however, the code mentioned above has two user-defined conversions.
- "9-999-9999" to
string
string
toSales_data
Why should literal string convert to string ? Is 9-999-9999
not a string
?