Hi,
May I know how to declare a Class in C++ window application form? Below is my code and error as shown below as well.
here is my class declaration:
ref class CLoadObj {
public:
bool ImportObj(t3DMo del *pModel, char *strFileName);
System::Void ReadObjFile(t3D Model *pModel);
System::Void ReadVertexInfo( System::Void);
System::Void ReadFaceInfo(Sy stem::Void);
System::Void FillInObjectInf o(t3DModel *pModel);
System::Void ComputeNormals( t3DModel *pModel);
System::Void SetObjectMateri al(t3DModel *pModel, int whichObject, int materialID);
private:
FILE *m_FilePointer;
vector<CVector3 > m_pVertices;
vector<tFace> m_pFaces;
vector<CVector2 > m_pTextureCoord s;
bool m_bObjectHasUV;
bool m_bJustReadAFac e;
};
#endif
Below is my declaration a Class in window form application, and the error was stated as below:
CLoadObj^ g_LoadObj = gcnew CLoadObj;
error when debugging:
1>d:\fyp\a3203s \ver2of opengl_on_a_win dows_form\openg l_on_a_windows_ form\OpenGL.h(1 7) : error C3145: 'g_LoadObj' : global or static variable may not have managed type 'CLoadObj ^'
I would like to use the g_LoadObj to replace the CLoadObj but Im unable to link to the specify class by using the g_LoadObj.
I had tried another method to declare:
CLoadObj* g_LoadObj = gcnew CLoadObj;
and the errors occured when debugging was as below:
1>d:\fyp\a3203s \ver2of opengl_on_a_win dows_form\openg l_on_a_windows_ form\OpenGL.h(1 7) : error C3699: '*' : cannot use this indirection on type 'CLoadObj'
1> compiler replacing '*' with '^' to continue parsing
1>d:\fyp\a3203s \ver2of opengl_on_a_win dows_form\openg l_on_a_windows_ form\OpenGL.h(1 7) : error C3145: 'g_LoadObj' : global or static variable may not have managed type 'CLoadObj ^'
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
Im unable to replace the class name by using the g_LoadObj. Im using window form application is it the syntax will be different from C++?
May I know how to declare a Class in C++ window application form? Below is my code and error as shown below as well.
here is my class declaration:
ref class CLoadObj {
public:
bool ImportObj(t3DMo del *pModel, char *strFileName);
System::Void ReadObjFile(t3D Model *pModel);
System::Void ReadVertexInfo( System::Void);
System::Void ReadFaceInfo(Sy stem::Void);
System::Void FillInObjectInf o(t3DModel *pModel);
System::Void ComputeNormals( t3DModel *pModel);
System::Void SetObjectMateri al(t3DModel *pModel, int whichObject, int materialID);
private:
FILE *m_FilePointer;
vector<CVector3 > m_pVertices;
vector<tFace> m_pFaces;
vector<CVector2 > m_pTextureCoord s;
bool m_bObjectHasUV;
bool m_bJustReadAFac e;
};
#endif
Below is my declaration a Class in window form application, and the error was stated as below:
CLoadObj^ g_LoadObj = gcnew CLoadObj;
error when debugging:
1>d:\fyp\a3203s \ver2of opengl_on_a_win dows_form\openg l_on_a_windows_ form\OpenGL.h(1 7) : error C3145: 'g_LoadObj' : global or static variable may not have managed type 'CLoadObj ^'
I would like to use the g_LoadObj to replace the CLoadObj but Im unable to link to the specify class by using the g_LoadObj.
I had tried another method to declare:
CLoadObj* g_LoadObj = gcnew CLoadObj;
and the errors occured when debugging was as below:
1>d:\fyp\a3203s \ver2of opengl_on_a_win dows_form\openg l_on_a_windows_ form\OpenGL.h(1 7) : error C3699: '*' : cannot use this indirection on type 'CLoadObj'
1> compiler replacing '*' with '^' to continue parsing
1>d:\fyp\a3203s \ver2of opengl_on_a_win dows_form\openg l_on_a_windows_ form\OpenGL.h(1 7) : error C3145: 'g_LoadObj' : global or static variable may not have managed type 'CLoadObj ^'
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
Im unable to replace the class name by using the g_LoadObj. Im using window form application is it the syntax will be different from C++?
Comment