美文网首页
C++ 匿名函数

C++ 匿名函数

作者: 贼噶人 | 来源:发表于2020-01-21 13:44 被阅读0次
class Hello2{
public:
    void func2(void (*m)(const char *data)){
        m("Hello World!");
    }
};

int main(const int argc, const char * argv[]) {
    
    Hello2 hello2;
    hello2.func2([](const char* data){
        std::cout << data << std::endl;
    });
return 0;
}

相关文章

网友评论

      本文标题:C++ 匿名函数

      本文链接:https://www.haomeiwen.com/subject/avrezctx.html