重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

重载逗号操作符

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

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP