2014-11-15 45 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