[ fromfile: types.xml id: moreconversion ]
Suppose that, for some reason, you needed to write your own String
class.[78]
You might produce a class definition with several constructors such as these:
class String { String(); // Creates an empty String of length 0 String(const char* str); // Converts a char array to a String explicit String(int n); // Creates length n String, filled // with spaces ... other member functions - but not constructors ... };
Describe the String
objects str1 and str2 produced by the following client code lines.
... String str1, str2; // construct two empty strings str1 = "A"; str2 = 'A'; ...
That is because char 'A'
would be promoted to the int
65 (the ASCII code for 'A'
) so that the third constructor could be (implicitly) called.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |