How to pass one function as an argument into another function in C++? [duplicate]

扶醉桌前 提交于 2019-12-25 11:14:11

问题


Functions are said to be first class objects in C++. How is it possible to replicate the following pyhton code in C++?

def print_wrapper(a):
    print(a)

def execute_function(func, arg):
    return func(arg)

execute_function(print_wrapper, 'test_argument')

Please note that the function print_wrapper is passed as an argument into the function execute_function.

来源:https://stackoverflow.com/questions/46265136/how-to-pass-one-function-as-an-argument-into-another-function-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!