重载函数调用运算符
时间:2014-01-21 00:32:35
收藏:0
阅读:366
将函数调用运算符“()”进行重载:
#include<iostream> using namespace std; class Add { public: double operator ()(double a,double b); }; double Add::operator() (double a,double b) { return a+b; } int main() { Add f; cout<<f(2.5,3.2)<<endl; return 0; }
输出:5.7
原文:http://blog.csdn.net/qsyzb/article/details/18400905
评论(0)