我尝试将方法从“curl_connector”类推送到curl函数。
让我们看看代码:
size_t curl_connector::write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
size_t written;
written = fwrite(ptr, size, nmemb, stream);
return written;
}
//execute from curl_connector.cpp and this class method
res = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, std::bind(&curl_connector::write_data,this));
我收到了错误,申请被关闭了。
我试试:
std::bind(&curl_connector::write_data);
std::bind(&curl_connector::write_data,curl_connector::getInstance()); //curl_connector is a singleton pattern
如果你给我一个例子,告诉我当write_data在其他类中时如何做同样的事情。