相关疑难解决方法(0)

如何在复制控制功能中处理C++数组成员?

这是我长期以来一直想知道的事情.请看以下示例:

struct matrix
{
    float data[16];
};
Run Code Online (Sandbox Code Playgroud)

我知道默认构造函数和析构函数在这个特定示例中做了什么(没有),但是复制构造函数和复制赋值运算符呢?

struct matrix
{
    float data[16];

    // automatically generated copy constructor
    matrix(const matrix& that) : // What happens here?
    {
        // (or here?)
    }

    // automatically generated copy assignment operator
    matrix& operator=(const matrix& that)
    {
        // What happens here?

        return *this;
    }
};
Run Code Online (Sandbox Code Playgroud)

它涉及std::copystd::uninitialized_copymemcpymemmove或什么?

c++ arrays copy-constructor assignment-operator

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