PDA

View Full Version : default argument compiler warning



TheKedge
27th March 2007, 15:30
quick question:

I've got a func
private:
int send(const QString command, QString& response = QString());

my compiler says:
non-standard: default argument: converting from class QString in calss QString&

inside the func I have
if (response.isNull())
return 0;
to check for the default argument.

what's wrong, and how should I define the default argument? is at all it important?
thanks...
K

high_flyer
27th March 2007, 15:57
Try this:


int send(const QString& command, const QString& response="" );

The problem in your code is that the second paramter is a reference but not const, and you can't have temp initialization on non const reference.
Note that I changed both to const reference, its more efficient that way.