定義了一個結構體
typedef struct binElement
{
float weight;
int voxelIndex;
}binElement;
再定義一個結構體,其中元素包含第一個結構體的元素
typedef struct LORData
{
binElement *pElement;
int LORIndex;
int voxelNum;
}LORData;
在main()函式中
LORData *List;
int a,b,c1,c2,...,d1,d2,...;//這幾個值假設都已經賦值;
for(int i=0;i<m;i++)
{
List->LORIndex=a;
List->voxelNum=b;
for(int j=0;j<n;j++)
{
List->pElement[j].weight=c1; //此處報錯顯示,不能將float*型別的值分配搭配float型別的物體
List->pElement[j].voxelIndex=d1; //此處報錯顯示,不能將int*型別的值分配搭配int型別的物體
}
}
uj5u.com熱心網友回復:
你貼出來的內容沒有問題,除了int voxelNum后面的分號是中文分號以外。uj5u.com熱心網友回復:
你好,main()函式中,有兩處報錯,

請問怎么修改這部分,多謝!
uj5u.com熱心網友回復:
光看這里看不出什么來。他說你的voxelID和weight是int*型別,那很可能就是。你再檢查檢查。
uj5u.com熱心網友回復:
你這兩個指標LORData* list和binElement *pElement都沒有分配空間啊。。。。uj5u.com熱心網友回復:
List->pElement[j].weight=c1;小白就是想問一下,pElement[j]你沒有定義陣列只是定義了pElement指標可以這么用嗎?
List->*pElement.weight=c1;這樣是不是好就可以了
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/233265.html
標籤:C++ 語言
