If you want to add files given at the command line to a list of file names, then you need to call a member function of a certain object (the file list) for each string given at the command line (the file names).
For cases like these an overloaded version of call exists, see the above.
Take a look at the example below:
#include <iostream>
#include <list>
#include <string>
#include "cmdline.h"
using namespace std;
using namespace cmdl; // defined in cmdline.h
int main(int argc, char *argv[])
{
typedef list<string> stringlist_t;
stringlist_t stringlist;
{
CmdLine CL;
CL.Init( --argc, ++argv ); // skip program name
// add arguments to a list
CL.Call("-add-strings-to-list", // command line option
stringlist, // object to call the member function for
&stringlist_t::push_back, // member function
CmdLine::cmdMultiple); // allow multiple arguments
CL.Done();
}
// print list of strings to stdout
stringlist_t::iterator current = stringlist.begin();
while (current != stringlist.end())
cout << *current++ << endl;
}
Note that this example does not include error handling, which is described here.