自己生成了一个三角形类,用于三维的三角面片顶点的设置。
class CFace:public CObject
{
public:
CFace();
virtual ~CFace();
private:
int _v1Index,_v2Index,_v3Index;
public:
BOOL SetVertexIndex3(int v1Index,int v2Index, int v3Index);
void GetVertexIndex3(int& v1Index,int& v2Index, int& v3Index);
};
大家知道,不同三维模型的三角形面片数量是不确定的。因此我希望使用CArray来动态管理一个三维模型的面片数据。
在CModel类中定义成员变量,
CArray<CFace,CFace&> m_faceList;
成员函数:
void AddFace(CFace& face);int CPart::AddFace(CFace& face)
{
return _faceList.Add(face);
}编译出现错误,如下:
d:\microsoft visual studio\vc98\mfc\include\afxtempl.h(443) : error C2582: 'CFace' : 'operator =' function is unavailable
d:\microsoft visual studio\vc98\include\xmemory(59) : while compiling class-template member function 'void __thiscall CArray<class CFace,class CFace &>::SetAtGrow(int,class CFace &)'
Generating Code...请各位大侠指点原因,如何改?
class CFace:public CObject
{
public:
CFace();
virtual ~CFace();
private:
int _v1Index,_v2Index,_v3Index;
public:
BOOL SetVertexIndex3(int v1Index,int v2Index, int v3Index);
void GetVertexIndex3(int& v1Index,int& v2Index, int& v3Index);
};
大家知道,不同三维模型的三角形面片数量是不确定的。因此我希望使用CArray来动态管理一个三维模型的面片数据。
在CModel类中定义成员变量,
CArray<CFace,CFace&> m_faceList;
成员函数:
void AddFace(CFace& face);int CPart::AddFace(CFace& face)
{
return _faceList.Add(face);
}编译出现错误,如下:
d:\microsoft visual studio\vc98\mfc\include\afxtempl.h(443) : error C2582: 'CFace' : 'operator =' function is unavailable
d:\microsoft visual studio\vc98\include\xmemory(59) : while compiling class-template member function 'void __thiscall CArray<class CFace,class CFace &>::SetAtGrow(int,class CFace &)'
Generating Code...请各位大侠指点原因,如何改?
添加函数CFace & operator = (CFace & msg);
还是在CFace类中添加,希望能给个详细的解答,最好能提供代码,谢谢
CFace(const CFace& face)
{
_v1Index = face._v1Index;
_v2Index = face._v2Index;
_v3Index = face._v3Index;
}CFace& operator = (const CFace& face)
{
_v1Index = face._v1Index;
_v2Index = face._v2Index;
_v3Index = face._v3Index;
return *this;
}还有建议不要从CObject继承,因为CObject有虚函数类的大小可能比较大。
动态管理不要使用CArray,Array是线形的,填加删除频繁对性能有影响 可以使用CList或者 list