الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مساعدة في هذا الكود باستخدام Oop

بدأه 852147 في 3 يوليو 2008 · 6 رد · 742 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بسم الله الرحمن الرحيم

لدي مشكلة مستعصية علي وهي سهلة لمن سهل الله عليه الأمر

يتمثل في أن لدي هذا الكلاس المسمسى point class

وبداخله عضو خاص private هو struct vertex

ولدي دالة اسمها int Getxyzcolor ( float Getx ,float Gety , float Getz,DWORD GetColor );

تتمثل مهمتها في الوصول الى عناصر vertex ولكني لاأستطيع ذلك خيث يظهر الخطأ التالي.

Error 1 error C2597: illegal reference to non-static member 'pointclass::vertex::x' c:\documents and settings\xppresp3\my documents\visual studio 2005\projects\buffer by oop\buffer by oop\buufer by oop.cpp 76

والخطأ

Error 2 error C2440: '=' : cannot convert from '' to 'float' c:\documents and settings\xppresp3\my documents\visual studio 2005\projects\buffer by oop\buffer by oop\buufer by oop.cpp 76

وهذا هو كود الكلاس

class pointclass

{

private:

struct vertex

{

FLOAT x , y ,z ;

DWORD color ;

};

VOID *pvertex ;

public:

int Getxyzcolor ( float Getx ,float Gety , float Getz,DWORD GetColor );

};

pointclass::Getxyzcolor ( float Getx ,float Gety , float Getz,DWORD GetColor )

{

Getx = vertex::x ;

}

ممكن مساعدة حول هذا الكود

وشكرا

#2

السلام عليكم :

بدلت WORD الى int يمكنك أعادته اذا اردت لكن يجب ان يكون معرف.

  1.  
  2. class pointclass
  3. {
  4. private:
  5. struct vertex
  6. {
  7. float x , y ,z ;
  8. int color ;
  9. };
  10. vertex pvertex;
  11. public:
  12. float Getx();
  13. float Gety();
  14. float Getz();
  15. int color();
  16. };
  17. float pointclass::Getx ( )
  18. {
  19. return pvertex.x ;
  20. }
  21. float pointclass::Gety()
  22. {
  23. return pvertex.y;
  24. }
  25. float pointclass::Getz()
  26. {
  27. return pvertex.z;
  28. }
  29. int pointclass::color()
  30. {
  31. return pvertex.color;
  32. }
  33.  

tvquran_6.gif

#3

شكرا على المساعدة فعلا

ولكن لدي مشكلة أخرى

لاأستطيع ادراج دالة من void

#4
class pointclass
{
private:
struct vertex
{
static float x , y ,z;
DWORD color;
};
void *pvertex; // ??!
public:
void Getxyzcolor ( float Getx ,float Gety , float Getz,DWORD GetColor );

};
void pointclass::Getxyzcolor ( float Getx ,float Gety , float Getz,DWORD GetColor )
{
Getx = vertex::x; 
}

ملاحظة :

لم ارى تنسيق الرؤوس FVF ؟ !

ربما يكون خارج الكلاس لكن انا افضل ان يكون داخل وايضا تعرف دالة لكي تشتق الرؤوس

struct Vertex{
	Vertex(){}
	Vertex(float x,float y,float z)
	{
		_x=x;_y=y;_z=z;
	}
	float _x,_y,_z,_nx,_ny,_nz,_u,_v;
	.
	.
	.
	.

};
llback.jpg

اشهد ان لا إله إلا الله وان محمدا ً رسول الله

#5

نعم أنت محق fvf خارج الكلاس

وشكرا على المساعدة التي سأحاول تطبيقها

الف شكرا

ماذا بخصوص الدوال من نوع void

#6
اقتباس
لاأستطيع ادراج دالة من void

لم افهم سؤالك تحديدا

هل تقصد ان تضيف دالة داخل الكلاس ؟

class pointclass
{
private:
struct vertex
{
static float x , y ,z;
DWORD color;
};
void *pvertex; // ??!
public:
void NewFunction();
void Getxyzcolor ( float Getx ,float Gety , float Getz,DWORD GetColor );

};
void pointclass::Getxyzcolor ( float Getx ,float Gety , float Getz,DWORD GetColor )
{
Getx = vertex::x; 
}

void pointclass::NewFunction()
{
	::MessageBox(0,"Empty",0,0);

}
llback.jpg

اشهد ان لا إله إلا الله وان محمدا ً رسول الله

#7

شكرا

مواضيع مشابهة