Reputation: 26640
Sorry, but I can't find a right place in C++ manual.
In a following string:
void setYRange(QString name1, int s1, int e1, QString name2 = 0, int s2 = 0, int e2 = 0);
I do not understand the initialization:
QString name2 = 0
Please give me just a reference to the right place in C++ manual.
Upvotes: 1
Views: 364
Reputation: 180415
What you are seeing is the compiler choosing the QString::QString(const QChar *unicode, int size = -1)
constructor. 0
is the null pointer value so a pointer can be implicitly constructed from it. That means to compiler will chose the c-string constructor and initialize the pointer to a null pointer. Since the pointer is null and that means you will construct an null QString
(it is empty).
Do note that this behavior is different from a std::string
. Constructing one of those from a null pointer is undefined behavior.
Upvotes: 2