微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

非标准语法;使用“&”创建指向成员 libcurl 的指针

如何解决非标准语法;使用“&”创建指向成员 libcurl 的指针

我有这个程序:

#include<iostream>
#include<curl/curl.h>
#include"Header.h"

size_t Data::write_callback(char* ptr,size_t size,size_t nmemb,void* userdata) {
    size_t instant_size = size * nmemb;

    for (int i = 0; i < instant_size; i++) {
        this->html.push_back(ptr[i]);
    }
    return instant_size;
}

void Data::setUrl(std::string url){
    this->url = url;
}

std::string Data::getHtml(void) {
    curl_global_init(CURL_GLOBAL_ALL);
    CURL* easy_handle = curl_easy_init();

    curl_easy_setopt(easy_handle,CURLOPT_URL,this->url);
    curl_easy_setopt(easy_handle,CURLOPT_WRITEFUNCTION,write_callback);
    curl_easy_perform(easy_handle);

    curl_easy_cleanup(easy_handle);
    curl_global_cleanup();

    return html;
}

文件是:

#include<iostream>

class Data {
    std::string html;
    std::string url;
    size_t write_callback(char*,size_t,void*);

public:
    Data();
    void setUrl(std::string);
    std::string getHtml();
};

当我运行程序时,我得到:
错误 C3867 'Data::write_callback':非标准语法;使用 '&' 创建一个指向成员的指针

有人可以帮我吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。