您好,欢迎来到化拓教育网。
搜索
您的当前位置:首页c++,函数调用运算符重载

c++,函数调用运算符重载

来源:化拓教育网

#include <iostream>
#include<stdlib.h>
using namespace std;
#include <stdio.h>
#include<string>
class My
{
public:
    void operator()(string test)
    {
        cout<<test<<endl;
    }
};
class Myadd
{
public:
    int operator()(int num1,int num2)//匿名对象
    {
        return num1+num2;
    }
};
void test02()
{
    Myadd myadd;
    myadd(100,100);
    int ret=myadd(100,100);
    cout<<ret<<endl;
    cout<<Myadd()(100,100)<<endl;
}
void test01()
{
    My my;
    my("hello ");

}
int main()
{
    //test01();
    test02();


    system("pause");
    return 0;
}
 

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuo9.cn 版权所有 赣ICP备2023008801号-1

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务