我有一个这样的结构:
/* Renderable definition */
struct Renderable
{
Renderable(VertexBufferPtr vertexBuffer, const Mat4& wvpMatrix, const Mat4& worldMatrix, const Vec4& diffuseColor, const float specularFactor) :
mVertexBuffer(vertexBuffer), mTransform(wvpMatrix, worldMatrix), mMaterial(diffuseColor, specularFactor)
{
}
/* Transform definition */
struct Transform
{
Transform(const Mat4& wvpMatrix, const Mat4& worldMatrix) : mWVPMatrix(wvpMatrix), mWorldMatrix(worldMatrix)
{
}
const Mat4 mWVPMatrix;
const Mat4 mWorldMatrix;
};
/* Material definition */
struct Material
{
Material(const Vec4& diffuseColor, const float specularFactor) : mDiffuseColor(diffuseColor), mSpecularFactor(specularFactor)
{
}
const Vec4 mDiffuseColor;
const float mSpecularFactor;
};
const VertexBufferPtr mVertexBuffer;
const Transform mTransform;
const Material mMaterial;
};
/* RenderQueue definition */
typedef std::vector<Renderable> RenderQueue;
当我尝试在我的代码中使用它时;
RenderQueue CreateRenderQueue(const Scene* scene);
....
RenderQueue renderQueue(CreateRenderQueue(activeScene));
我收到以下编译错误:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2514): error C2582: 'operator =' function is unavailable in 'Renderable'
经过一番挖掘,我意识到这是因为我没有定义赋值运算符和复制构造函数。然后我就这样做了,瞧!它编译...
....我的问题是,为什么赋值运算符和复制构造函数不是由编译器隐式生成的?(vs2010)我没有定义它们,所以肯定会生成它们吗?
谢谢