What is the difference between QString::number(0) and ((const char*) 0)?
I want to initialize a QString say phoneNumber to null. Will phoneNumber(QString::number(0)) and phoneNumber((const char*) 0) both work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To create a null
QStringjust default initialize it:Note that
QString::number(0)is decidedly not null – it creates a QString with the value"0".You could also initialize the
QStringwith aNULLpointer, but I wouldn’t recommend it unless you’re passing a pointer regardless of whether it’sNULLor not (i.e., it could sometimes point to a C string) since it’s unnecessary.You should also understand the following Qt docs: