c++中的指针数组

pointer array in c++

本文关键字:数组 指针 c++      更新时间:2023-10-16

我有一个指针数组的问题。

struct sFace {
sPoint* points[2];        
sCell*  neighCells[2];
sFace*  neighFaces[4];
double* neighPe[4];
double* neighF[4];}
struct sCell {
   sFace*   faces[4];  
   sPoint*  points[4];
   sCell*   neighCells[4];
}
and
curFace = &data->faces[faceId];
curCell = &data->cells[cellId];

为什么不能在:

中使用&
curFace->neighFaces[1]&= curFace->neighCells[1]->faces[1];

根据此,&=是位赋值运算符。

如果你是c++编程新手,请阅读c++ Fundamentals

因为没有为指针定义位&操作符:

curFace->neighFaces[1]

neighFaces是a:

sCell*   neighCells[4];

因此,curFace->neighFaces[1]sCell *,并且没有为指针定义位&运算符。