diff --git a/src/cmlib-example/main.cpp b/src/cmlib-example/main.cpp index 5cc645f..f016ec8 100644 --- a/src/cmlib-example/main.cpp +++ b/src/cmlib-example/main.cpp @@ -3,6 +3,18 @@ #include #include +// function args by ref +int sum(QStringList sl) +{ + int s = 0; + for(auto str: sl) + { + s += str.toInt(); + } + return s; +} + + int main( int argc, char** argv ) { QCoreApplication app( argc, argv ); @@ -17,10 +29,20 @@ int main( int argc, char** argv ) // loop add ref QStringList sl; - for (auto s: sl) + sl << "111" << "222" << "333"; + for (const auto &s: sl) { qDebug() << s; } + // loop qasconst + for (auto s: sl) + { + s.append("0"); + } + + // function args by ref + auto ir = sum(sl); + return( 0 ); }