首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

JAVA之等号、传种对象参数与c++的区别

2013-09-05 
JAVA之等号、传类对象参数与c++的区别# include iostreamusing namespace stdclass ClassA{private:int

JAVA之等号、传类对象参数与c++的区别

# include <iostream>using namespace std;class ClassA{private:    int value;public:    void seta(int value)    {        this->value = value;    }    void show()    {        cout<<"the value : "<<value<<endl;    }};int main (){    ClassA a;    a.seta(3);    a.show();    cout<<"a:"<<&a<<endl;    ClassA b;    b.seta(4);    b.show();    cout<<"b:"<<&b<<endl;    b = a;    a.show();    b.show();    cout<<"a:"<<&a<<", b"<<&b<<endl;    b.seta(6);    a.show();    b.show();    cout<<"a:"<<&a<<", b"<<&b<<endl;}


运行结果:

the value : 3
a:0x22fefc
the value : 4
b:0x22fef8
the value : 3
the value : 3
a:0x22fefc, b0x22fef8
the value : 3
the value : 6
a:0x22fefc, b0x22fef8


Process returned 0 (0x0)   execution time : 0.132 s
Press any key to continue.

热点排行