相关疑难解决方法(0)

std :: array copy语义

#include <array>
#include <iostream>

using namespace std;

struct SimpleDebugger
{
    SimpleDebugger(int val = 0) : x(val) {
        cout << "created" << endl;
    }

    SimpleDebugger(const SimpleDebugger &that) : x(that.x) {
        cout << "copied" << endl;
    }

    ~SimpleDebugger() {
        cout << "killed!" << endl;
    }

    int getX() const {
        return x;
    }

    void setX(int val) {
        x = val;
    }

private:
    int x;
};

array<SimpleDebugger, 3> getInts(int i)
{
    array<SimpleDebugger, 3> a;
    a[0].setX(i);
    a[1].setX(i + 1);
    a[2].setX(i + 2);
    cout << "closing …
Run Code Online (Sandbox Code Playgroud)

c++ arrays copy copy-constructor c++11

1
推荐指数
1
解决办法
5143
查看次数

标签 统计

arrays ×1

c++ ×1

c++11 ×1

copy ×1

copy-constructor ×1