2014-11-15 78 views
4

我觉得我的问题真是小巫见大巫,但我不能让它的工作,当然仍然如何设置标志(CPP-NETLIB)

std::string url="www.google.it"; 

boost::network::http::client client1_(_follow_redirects=true, _cache_resolved=true); 
boost::network::http::client::request req(url); 
boost::network::http::client::response resp = client1_.get(req); 
std::cout << "Body: " << body(resp) << std::endl; 

return 0; 

错误指的是标志的声明。 ..但我如何设置它们?

 
/home/snake91/cpp_pricing/underlying.cpp:67: error: C++ requires a type specifier for all declarations 
    boost::network::http::client client1_(_follow_redirects=true, _cache_resolved=true);

^

回答

3
client::options options; 
options.follow_redirects(true) 
     .cache_resolved(true); 

client client1_(options); 

从这个页面的文档的:http://cpp-netlib.org/0.11.0/reference/http_client.html#general

+1

谢谢,其实我一直在寻找在这里 http://cpp-netlib.org/0.9.1/reference_http_client.html 和刚刚意识到语法已经从0.9 ... + 1改为再次感谢! – 2014-11-15 00:21:54

+1

@VittorioApicella不错。我不知道。这只是第二双眼睛,有时候会诀窍:) – sehe 2014-11-15 00:25:45