首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

成员函数的有关问题

2012-11-11 
成员函数的问题我在类Model中定义了一个public结构体typedef struct {char name[20]int vertices_qtyint

成员函数的问题
我在类Model中定义了一个public结构体
typedef struct {
char name[20];
   
int vertices_qty;
  int polygons_qty;

  vertex_type vertex[MAX_VERTICES]; 
  polygon_type polygon[MAX_POLYGONS];
  mapcoord_type mapcoord[MAX_VERTICES];
  int id_texture;
} obj_type, *obj_type_ptr;
然后又定义了一个public成员函数 char Load3DS(obj_type_ptr, char);

char Model::Load3DS(obj_type_ptr p_object, char *p_filename)
{
  int i; //Index variable

FILE *l_file; //File pointer

unsigned short l_chunk_id; //Chunk identifier
unsigned int l_chunk_lenght; //Chunk lenght

unsigned char l_char; //Char variable
unsigned short l_qty; //Number of elements in each chunk

unsigned short l_face_flags; //Flag that stores some face information

if ((l_file=fopen (p_filename, "rb"))== NULL) return 0; //Open the file

while (ftell (l_file) < filelength (fileno (l_file))) //Loop to scan the whole file 
{
//getche(); //Insert this command for debug (to wait for keypress for each chuck reading)

fread (&l_chunk_id, 2, 1, l_file); //Read the chunk header
printf("ChunkID: %x\n",l_chunk_id); 
fread (&l_chunk_lenght, 4, 1, l_file); //Read the lenght of the chunk
printf("ChunkLenght: %x\n",l_chunk_lenght);

switch (l_chunk_id)
  {
case 0x4d4d: 
break;  

//----------------- EDIT3DS -----------------
// Description: 3D Editor chunk, objects layout info 
// Chunk ID: 3d3d (hex)
// Chunk Lenght: 0 + sub chunks
//-------------------------------------------
case 0x3d3d:
break;

//--------------- EDIT_OBJECT ---------------
// Description: Object block, info for each object
// Chunk ID: 4000 (hex)
// Chunk Lenght: len(object name) + sub chunks
//-------------------------------------------
case 0x4000: 
i=0;
do
{
fread (&l_char, 1, 1, l_file);
  p_object->name[i]=l_char;
i++;
  }while(l_char != '\0' && i<20);
break;

case 0x4100:
break;

//--------------- TRI_VERTEXL ---------------
// Description: Vertices list
// Chunk ID: 4110 (hex)
// Chunk Lenght: 1 x unsigned short (number of vertices) 
// + 3 x float (vertex coordinates) x (number of vertices)
// + sub chunks
//-------------------------------------------


default:
fseek(l_file, l_chunk_lenght-6, SEEK_CUR);
  } 
}
fclose (l_file); // Closes the file stream
return (1); // Returns ok
}
但是当我在workspace中点Load3DS(obj_type_ptr p_object, char *p_filename),显示“找不到这个函数的定义”,这是什么原因啊?希望大神解答


[解决办法]
引用了它的头文件没?

热点排行