#define INPUT_CNT 5
struct InputDataInfo
{
int iVal;
double dVal;
};
void struct2PointerTest()
{
InputDataInfo* pInfo[INPUT_CNT] = {0};
for (size_t i = 0; i < INPUT_CNT; i++)
{
pInfo[i] = new (std::nothrow) InputDataInfo();
if (pInfo[i])
{
pInfo[i]->iVal = i;
pInfo[i]->dVal = i * 0.3;
}
}
for (size_t i = 0; i < INPUT_CNT; i++)
{
if (pInfo[i])
{
delete pInfo[i];
pInfo[i] = nullptr;
}
}
return;
}
结构体二级指针使用示例
最新推荐文章于 2024-08-14 18:03:05 发布