重载逗号操作符-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

重载逗号操作符

#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://kswsj.cn/article/johgjd.html

其他资讯