标签:重载 ring ext pre pause print 仿函数 ++ end
#include<iostream> #include<string> using namespace std; class MyPrint { public: void operator()(string text) { cout << text << endl; } }; class MyAdd { public: int operator()(int n1, int n2) { return n1 + n2; } }; int main() { MyPrint mp; mp("hello c++");//仿函数 cout << MyAdd()(100, 100) << endl; system("pause"); return 0; }
标签:重载 ring ext pre pause print 仿函数 ++ end
原文地址:https://www.cnblogs.com/lyt888/p/12488625.html