Results 1 to 2 of 2

Thread: default argument compiler warning

  1. #1
    Join Date
    Jan 2006
    Munich, Germany.
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4

    Default default argument compiler warning

    quick question:

    I've got a func
    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?

  2. #2
    Join Date
    Jan 2006
    Munich, Germany
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows

    Default Re: default argument compiler warning

    Try this:
    Qt Code:
    1. int send(const QString& command, const QString& response="" );
    To copy to clipboard, switch view to plain text mode 
    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.

Similar Threads

  1. Warning QString::arg() argument missing
    By quickNitin in forum Newbie
    Replies: 9
    Last Post: 16th November 2006, 19:13
  2. Compiling custom Qt3 Widgets Gives warning in VC++6 Compiler
    By sunil.thaha in forum Qt Programming
    Replies: 4
    Last Post: 9th June 2006, 12:44
  3. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05:23
  4. a Text Editor with line numbers...
    By fullmetalcoder in forum Qt Programming
    Replies: 47
    Last Post: 5th April 2006, 11:10
  5. warning message on compile not understood
    By impeteperry in forum Qt Programming
    Replies: 13
    Last Post: 23rd January 2006, 23:36


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.