CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010
    Posts
    46

    [RESOLVED] Frustration with pointers...

    hello. I'm trying to implement 3DS models loader and found a tut to help me. And i found piece of code wich i cannot understand. Like title says it's about pointers. I think that that code is incorrect but compiler gives me no errors...
    Code:
    //I have these structures
    typedef struct tagFACE
    {
    	unsigned int a, b, c;
    	int MaterialID;
    }stFace;
    
    struct stMesh
    {
    	...
    	stFace* pFace;
    	...
    
    	stMesh()
    	{
    		...
    		pFace = NULL;
    		...
    	}
    };
    
    struct stObject
    {
    	int MeshsNum, MaterialsNum;
    	std::vector<stMesh> pMeshs;
    	std::vector<stMaterial> pMaterials;
    
    	stObject()
    	{
    		MeshsNum = MaterialsNum = 0;
    	}
    };
    
    //And i found this cycle
    stMesh *pMesh = &(pObject->pMeshs[pObject->MeshsNum-1]);
    for(int i=0; i<FacesNum; i++)
    {
    	pMesh->pFace[Index].MaterialID = MaterialID; /*I cannot understand how this index can be okay?*/
    }
    Thanks in advance

  2. #2
    Join Date
    Oct 2010
    Posts
    46

    Re: Frustration with pointers...

    Sorry i found where pObject->pMeshs[pObject->MeshsNum-1].pFace whas assigned to new stFace [FacesNum]. I guess i should take a break. :P

  3. #3
    Join Date
    Aug 2011
    Posts
    10

    Re: [RESOLVED] Frustration with pointers...

    Pointer is actually an array.

    Index is "i" as in
    pMesh->pFace[i].MaterialID = MaterialID;

    ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured