Suppose we have a class String:
class String {
public:
String (int n);
String(const char *p);
}
What will happen if we try:
String mystring='x';
Here it is written that the char 'x' will be converted to int and will call String(int) constructor. However, I do not understand it.
First, how 'x' can be converted to int? I can imagine that "3"
will be converted to 3
but what "x" will be converted to? Second, we have two constructors in the class. The first constructor takes one argument of int type and another constructor takes a pointer to char variable as an argument. Now we try to call not existing constructor that takes char as an argument. So, we convert char to integer, but why we do not try to convert char to pointer to char and then use the second constructor?