Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-05-12 00:57:15


Hi Susan,

> void Report::PrintName(const string name)
> {
> cout << " the log name is " << name << "\n";
> }
>
> void Report::InitCmdOpts(void)
> {
> try {
> p_opts = new po::options_description("Reporting");
> p_opts->add_options()
> ("log",
> po::value< string >()
> ->default_value("sys.log")
> ->notify( &Report::PrintName))
> ;

In this context the library expects you to pass a function that takes
'string' and returns nothing. However, you pass a member function, which
has implicit 'this' argument. I'd suggest this:

   #include <boost/bind.hpp>

   .....

        ->notify(boost::bind(&Report::PrintName, this, _1))

HTH,
Volodya


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net