[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-users
Subject:    Re: [Boost-users] Program Options not saving the values
From:       Vladimir Prus <ghost () cs ! msu ! su>
Date:       2014-07-02 7:13:18
Message-ID: 53B3B10E.4070407 () cs ! msu ! su
[Download RAW message or body]

On 07/02/2014 02:02 AM, Angelo Mondaini wrote:

Hi Angelo,

>      std::cout << "var: " <<  add << std::endl;
>      std::cout << "vm: " <<  vm["add"].as<int>() << std::endl;
>      po::notify(vm);
>
>      return 1;
> }
>
> Compiling and running:
> $ g++ program_options.cpp -lboost_program_options
> $ ./a.out --add 4
> var: 5
> vm: 4
>
> Why the value of the variable "add" is not receiving 4?

Because 'add' is only assigned when you call po::notify, and your program prints the value
of 'add' before calling po::notify

- Volodya


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic