阅读背景:

C ++ - 使用指针作为数据字段复制构造函数

来源:互联网 

I have the following code :-

我有以下代码: -

#include <iostream>
using namespace std;

class A { 
    int *val;
public:
    A() { val = new int; *val = 0; }
    int get() { return ++(*val); } 
};

int main() {
    A a,b = a;

    A c,d = c;

    cout << a.get() << b.get() ;
    cout << endl ; 

    cout << c.get() << endl ;//
    cout << d.get() << endl;
    return 0;
}
#in



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: