View Full Version : A doubt about initialization of variables
vcp
10th December 2009, 17:52
Hi,
When I initialize a variable of this way:
QString str=QString() or
QStringList lst=QStringList() what exactly accours? What value is assigned to the variable?
Thanks in advanced
spirit
10th December 2009, 18:45
in the first example an empty string in the second an empty list. :)
vcp
10th December 2009, 19:18
Thanks spirit.
squidge
10th December 2009, 20:00
You'll also notice this in the documentation.
QString::QString ()
Constructs a null string. Null strings are also empty.
QStringList::QStringList ()
Constructs an empty string list.
JohannesMunk
11th December 2009, 01:18
and those default constructors are called here as well, without any superficial assignment operation...
QString str;
QStringList sl;
You can call some other constructor than the default constructor like this:
QString str("yep");
QStringList sl(str);
HIH
Johannes
vcp
11th December 2009, 10:42
Hi people,
Thanks by all answers.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.