Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Value for qmap optional parameter

I'm working in C++ and want to create a function with an optional parameter that is a QMap. The question is what do I set the default value to. I want it to be an empty map.

void function(int i, QMap< QString, QString > MyMap = ???)

what do you put for ???

like image 355
user3685722 Avatar asked Oct 20 '22 17:10

user3685722


1 Answers

Question:

what do you put for ???

  1. You can put a default constructed object.

    void function(int i, QMap< QString, QString > MyMap = QMap<QString, QString>())
    
  2. You can put a call to a function that returns a compatible object.

    QMap< QString, QString > const& foo();
    void function(int i, QMap< QString, QString > MyMap = foo())
    
like image 189
R Sahu Avatar answered Oct 27 '22 08:10

R Sahu