重载逗号操作符

#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://bzwzjz.com/article/johgjd.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 外贸营销网站建设 成都网站建设 定制网站设计 重庆外贸网站建设 成都网站设计 企业网站建设 成都网站设计 成都网站建设 app网站建设 定制网站设计 成都网站建设 高端网站设计 营销型网站建设 成都网站制作 成都网站制作 成都企业网站制作 成都商城网站制作 成都网站设计 成都网站建设 成都网站建设 自适应网站设计 达州网站设计