Why QFile(“./test”) work though [Class QFile] has no QFile(char* s) constructor

Consider the statement:


It leads to the creation of a temporary object of type QString under the hood and thus the constructor QFile(const QString &name) is invoked.
As mentioned by @meetaig in the comments it’s possible because:

QString supports initialization using char*

Or better, as noted in the comments by @Slava – const char * in this case.

That’s all.

Browse More Popular Posts

Leave a Comment