我遇到了一些包含以下内容的代码:
struct ABC {
unsigned long array[MAX];
} abc;
Run Code Online (Sandbox Code Playgroud)
何时使用这样的声明是有意义的?
这是我长期以来一直想知道的事情.请看以下示例:
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::copy或std::uninitialized_copy或memcpy或memmove或什么?