【发布时间】:2011-05-09 00:50:31
【问题描述】:
这是我想了很久的事情。举个例子:
struct matrix
{
float data[16];
};
我知道这个具体例子中默认的构造函数和析构函数做了什么(什么都不知道),但是拷贝构造函数和拷贝赋值运算符呢?
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;
}
};
是否涉及std::copy或std::uninitialized_copy或memcpy或memmove或什么?
【问题讨论】:
-
这不是真正的 C,而是(主要是)C++。
-
@DervinThunk 我把问题的标题从 C 改成了 C++
标签: c++ arrays copy-constructor assignment-operator