重载逗号操作符-成都快上网建站

重载逗号操作符

#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://kswjz.com/article/johgjd.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流