gpt4 book ai didi

C++结构数组初始化

转载 作者:太空狗 更新时间:2023-10-29 21:26:21 26 4
gpt4 key购买 nike

我有以下结构:

struct localframepos
{
double ipos; //local room frame i(x) coordinate, in mm
double cpos; //local room frame c(y) coordinate, in mm
double rpos; //local room frame r(z) coordinate, in mm

localframepos()
{
ipos = 0;
cpos = 0;
rpos = 0;
}
localframepos(double init_ipos, double init_cpos, double init_rpos) //init constructor
{
ipos = init_ipos;
cpos = init_cpos;
rpos = init_rpos;
}
};

如何获得以下功能:

localframepos positions[] = { {0, .5, .2},
{4.5, 4, .5} };

最佳答案

删除构造函数。要使用大括号初始化,类型必须是 POD。

关于C++结构数组初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11894171/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com