//构建类型
struct ElementInfo
{
//1:代表墙 2:代表柱 3:代表板
int lable = 0;
WallInfo wall;
ColumnInfo column;
BoardInfo board;
};
//存构件信息ElementTypeInfo
void CExportYjk::SetElementsInfo(vector<ElementInfo>& ele, int tag, void* data)
{
ElementInfo info;
info.lable = tag;
switch (tag)
{
case 1:
info.wall = *(WallInfo*)data;
break;
case 2:
info.column = *(ColumnInfo*)data;
break;
case 3:
info.board = *(BoardInfo*)data;
break;
default:
break;
}
ele.push_back(info);
}
//使用方法
//存储墙信息
WallInfo* shapeInfo=new WallInfo();
shapeInfo->sectID = sectID;
shapeInfo->line = line;
SetElementsInfo(elesFloor[elevId],1,shapeInfo);
delete shapeInfo;
示例:不过void指针不安全,在C++17中可以用std::any方法去使用,安全