RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
花括号操作符重载
#include 
using namespace std;

class Square{
public:
    double operator()(double x)const{
        return x * x;
    }
    int operator()(int a,int b,int c=0)const{
        return a+b-c;
    }
};

int main(void){
    Square sq;
    //括号里面的参数会被自动当作形参传入
    cout << sq(12) << endl; //144
    cout << sq(1,5,3) << endl; //3
    cout << sq(1,3) << endl; //4
    return 0;
}

分享文章:花括号操作符重载
转载注明:http://scyingshan.cn/article/gcdccg.html