函数对象:可以定义函数对象。
sort(this->sprites.begin(), this->sprites.end(), [](const struct SpriteInfo & s1, const struct SpriteInfo & s2) { return s1.priority > s2.priority; }); typedef function<void (string &)> callback; void func(string &data) { data = "YES"; cout << data << endl; } void callee(string &data, callback call) { call(data); } int main() { string data; //callback call = &(func); //callee(data, call); callback call = [] (string data) { cout << "YES" << endl; }; call(data); return 0; }