next up previous contents
Next: Input files Up: GetPot Version 1.0 Powerful Previous: Nominus Arguments   Contents

Direct access to command line arguments

The very simplest way to access the argument list one is to use the -operator:

    while( cl[5] ) cout << cl[5] << endl;
The []-operator returns a zero pointer in case that one tried to reference an option that does not exists. Similar to that, the get()-functions allow to specify a type through a default argument, so that one writes for example:
    const double Acceleration = cl.get(5, 9.81);
to use argument number five as the value of a certain double variable. The high flexibility of GetPot, however, makes these methods seem to be a little outdated. Fixing the position of an argument in a argument list, is a restriction that makes the use of a program unnecessarily difficult. As seen preceeding sections, one can do much better without adding any more programming effort.

Frank-Rene Schaefer 2002-09-14