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:

public ref class CLoadObj {

public:
	
		
	bool ImportObj(t3DModel *pModel, char *strFileName);

	
	System::Void ReadObjFile(t3DModel *pModel);

	System::Void ReadVertexInfo(System::Void);

	System::Void ReadFaceInfo(System::Void);

	System::Void FillInObjectInfo(t3DModel *pModel);

	System::Void ComputeNormals(t3DModel *pModel);

	System::Void SetObjectMaterial(t3DModel *pModel, int whichObject, int materialID);

private:

	FILE *m_FilePointer;

	vector<CVector3>  m_pVertices;

	vector<tFace> m_pFaces;

	vector<CVector2>  m_pTextureCoords;

	bool m_bObjectHasUV;

	bool m_bJustReadAFace;
};


#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_windows_form\opengl_on_a_windows_form\OpenGL.h(17) : error C3145: 'g_LoadObj' : global or static variable may not have managed type 'CLoadObj ^'

Im unable to link to the specify class by using the g_LoadObj.
Is there anyone can help? Thanks a lot...

Below is my declaration a Class in window form application, and the error was stated as below:

CLoadObj^ g_LoadObj = gcnew CLoadObj;

I believe you mean CLoadObj* g_LoadObj = gcnew CLoadObj;

I had tried to put CLoadObj* g_LoadObj = gcnew CLoadObj;
and the errors occured when debugging was as below:

1>d:\fyp\a3203s\ver2of opengl_on_a_windows_form\opengl_on_a_windows_form\OpenGL.h(17) : error C3699: '*' : cannot use this indirection on type 'CLoadObj'
1> compiler replacing '*' with '^' to continue parsing
1>d:\fyp\a3203s\ver2of opengl_on_a_windows_form\opengl_on_a_windows_form\OpenGL.h(17) : 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++?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.