struct ObsSet //测量次数
{
int Count; /// <一测回所测点数
double *ets;
~ObsSet() {if(ets!=NULL) delete []ets;}
//ObsSet():Count(0){ets=NULL;}
ObsSet(int count):Count(count),ets(new double[count])
{
//ets=new double [Count]; //包括上半测回和下半测回
}
};
//再定义一个:
struct ObsStation /// <测站
{
std::string Name; /// <测站名 -- 不能为空白
double Height; /// <测站高, 对于自由设置而言,为0
double X,Y,Z; /// <测站三维坐标,对自由设站而言均为0
int CountOfTarget; /// <测点数
int CountOfObsSet; /// <测回数Observation set
ObsSet *ets;
ObsStation(int ct,int co):CountOfTarget(ct),CountOfObsSet(co) ,ets(0)
{
char* p = new char[sizeof(ObsSet)*CountOfObsSet]; ///问题就在这里
for( int i=0; i < CountOfObsSet ; i ++ ){
new( p+ i*sizeof(ObsSet) )ObsSet(CountOfObsSet);
}
ets = (ObsSet *)p;
}
~ObsStation()
{
for( int i=0; i < CountOfObsSet ; i ++ ){
//ObsSet* p = ( p+ i*sizeof(ObsSet) );
ets[i].~ObsSet();
}
delete (char*)ets;
}
};
int main(int argc, char* argv[])
{
ObsStation xx(10,2);
return 0;
}