重载逗号操作符

#include 
#include 

using namespace std;

class Comma{

private:
    int mvalue;
public:
    Test ( int i ){

        this->mvalue = i;
    }
    int value ( void ){

        return mvalue;
    }

};

Comma& operator , ( const Comma& a, const Comma& b ){

        return const_cast (b);
}

void func ( Comma& i ){

    cout << "func(): i = " << i.value() << endl;
}

int main ( int argc, char** argv ){

    Comma t0(0);
    Comma t1(1);

    Comma tt = ( t0, t1 );

    cout << tt.value() << endl;

    system ( "pause" );
    return 0;
}

新闻名称:重载逗号操作符
转载源于:http://lszwz.com/article/johgjd.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款