Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] error: default argument missing ?
QtWS25 Last Chance

[solved] error: default argument missing ?

Scheduled Pinned Locked Moved General and Desktop
default argumen
3 Posts 2 Posters 8.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    deleted28
    wrote on 28 May 2015, 11:52 last edited by deleted28
    #1

    Hello,
    do i always need to assign all functionparametrs a default value when giving at least a single one except it's the last parameter ?

    in header

    void logIt(quint8 _level=0b11111111, QString _dir="**", QByteArray _ba=NULL);
    
    void logIt(quint8 _level, QString _dir, QByteArray _ba);
    
    void logIt(quint8 _level, QString _dir, QByteArray _ba=NULL);
    

    all the above are OK, but not :

    void lvoid logIt(quint8 _level=0b11111111, QString _dir, QByteArray _ba=NULL);
    
    void logIt(quint8 _level=0b11111111, QString _dir="**", QByteArray _ba);
    

    error: default argument missing for parameter 3 of 'void

    1 Reply Last reply
    0
    • D Offline
      D Offline
      darkp03
      wrote on 28 May 2015, 11:59 last edited by
      #2

      The default parameters must always be the last ones., for example

      void Function( unsigned char a, unsigned char b, unsigned char c=0x20);
      

      Will work nicely, but

      void Function( unsigned char a, unsigned char b =0x20, unsigned char c);
      

      Wont compile, on your case, you can fix it easily just by changing the order in the parameters

      void logIt(QByteArray _ba, quint8 _level=0b11111111, QString _dir="**")
      
      1 Reply Last reply
      0
      • D Offline
        D Offline
        deleted28
        wrote on 28 May 2015, 12:07 last edited by
        #3

        Yes, sure, and it makes sense, thank you

        1 Reply Last reply
        0

        3/3

        28 May 2015, 12:07

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved