Q:

Error while compiling Boost.Bind

Invocation with boost::function f2 works fine, but the similar invocation for boost f3 is not compiling. The function fun3 which f3 points to contains two arguments std::ostream and const char* which is not compiling. Can someone please help me with figuring out what I am doing wrong here?
1>Compiling...
1>BostFunction.cpp
1>c:\libraries\boost_1_57_0\boost\bind\bind.hpp(69) : error C2825: 'F': must be a class or namespace when followed by '::'
1>        c:\libraries\boost_1_57_0\boost\bind\bind_template.hpp(15) : see reference to class template instantiation 'boost::_bi::result_traits<R,F>' being compiled
1>        with
1>        [
1>            R=boost::_bi::unspecified,
1>            F=void (__thiscall World::* )(std::ostream &,const char *)
1>        ]
1>        d:\vs projects\boost\bostfunction\bostfunction\bostfunction.cpp(34) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled
1>        with
1>        [
1>            R=boost::_bi::unspecified,
1>            F=void (__thiscall World::* )(std::ostream &,const char *),
1>            L=boost::_bi::list2<boost::_bi::value<World *>,boost::arg<1>>
1>        ]
1>c:\libraries\boost_1_57_0\boost\bind\bind.hpp(69) : error C2039: 'result_type' : is not a member of '`global namespace''
1>c:\libraries\boost_1_57_0\boost\bind\bind.hpp(69) : error C2146: syntax error : missing ';' before identifier 'type'
1>c:\libraries\boost_1_57_0\boost\bind\bind.hpp(69) : error C2208: 'boost::_bi::type' : no members defined using this type
1>c:\libraries\boost_1_57_0\boost\bind\bind.hpp(69) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>Build log was saved at "file://d:\VS Projects\Boost\BostFunction\BostFunction\Debug\BuildLog.htm"

class World
{
public:
    void test() {
        void fun2(int i)  { cout << i << endl; }            
        void fun3(std::ostream &os, const char* str)
        {
            os << str << endl;
        }

        boost::function<void (int)> f2( boost::bind( &World::fun2, this, _1 ) ); // Works Fine
        boost::function<void (std::ostream &os, const char* str)> f3( boost::bind( &World::fun3, this, _1 ) ); // How to make this work?

        f2(111);
        f3(boost::ref(std::cout), "Hello World");
    }
};

int main()
{
    boost::function<void(World*, std::ostream&, const char*)>f2 = &World::fun3;
    World w;
    f2(&w, boost::ref(std::cout), "Hello World"); // Works Fine

    World w;
    w.test();
}

A:

your boost::function type specification is wrong for f3
fun2 takes an int parameter and returns void so you correctly declare 
boost::function<void (int)> f2;

fun3 has a different parameter list so the boost function must be declared to match:
boost::function<void (std::ostream &, const char*)> f3;

I also don't understand this line:
boost::function<void(World*, std::ostream&, const char*)>f2 = &World::Hello;

because I don't see a member of World named Hello.
recommended changes
If you have access to c++11, I'd recommend using new features. Boost::bind is entirely superceded by lambda and std::function or auto can be used instead of boost::function.
consider:
class World
{
  public:
    void test() {
        auto f2([](int i){ std::cout << i << std::endl; });
        auto f3([](std::ostream &os, const char* str){ os << str << std::endl });

        f2(111);
        f3(boost::ref(std::cout), "Hello World");
    }
};

You can also use auto with boost::bind instead of the lambda if you wish (not recommended for clarity and link requirements) and you can use std::function with lambda if you wish (declared the same way you would for boost::bind.

