
C++ struct初始化
发布日期:2021-05-06 19:47:43
浏览次数:22
分类:技术文章
本文共 933 字,大约阅读时间需要 3 分钟。
C++ struct初始化
struct初始化
摘自:
The field identifiers are indeed C initializer syntax. In C++ just give the values in the correct order without the field names. Unfortunately this means you need to give them all (actually you can omit trailing zero-valued fields and the result will be the same).
在C++中初始化struct不需要寫出各field的名字,只需要確保各值的順序與field在struct中的順序一致就行。
在getopt.h
中定義了struct option
:
struct option { const char *name; int has_arg; int *flag; int val;};
在TensorRT/samples/common/argsParser.h
中,對struct option
型別的變數進行初始化:
static struct option long_options[] = { { "help", no_argument, 0, 'h'}, { "datadir", required_argument, 0, 'd'}, { "int8", no_argument, 0, 'i'}, { "fp16", no_argument, 0, 'f'}, { "useILoop", no_argument, 0, 'l'}, { "useDLACore", required_argument, 0, 'u'}, { "batch", required_argument, 0, 'b'}, { nullptr, 0, nullptr, 0}};
參考連結
发表评论
最新留言
感谢大佬
[***.8.128.20]2025年03月30日 10时25分55秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
好看清新卡通人物404单页网站源码
2019-03-01
简洁仿t猫404页html源码
2019-03-01
Kotlin实现冒泡排序
2019-03-01
NodeJS下TypeScript环境安装
2019-03-01
汽车后市场,小程序为何独占鳌头
2019-03-01
短视频小程序,互联网新风口
2019-03-01
Mybatis-plus代码生成器模板(MySQL数据库)
2019-03-01
使用redis管理Mybatis的二级缓存
2019-03-01
使用redis管理Mybatis-Plus的二级缓存
2019-03-01
Mybatis中的SQL语句等于、不等于和模糊查询的语法
2019-03-01
使用 github 搜索
2019-03-01
java有包名的类访问没有包名的类
2019-03-01
整型关键字的散列映射
2019-03-03
多位水仙花数-python(出现运行超时?不妨用减法计算)
2019-03-03
地下迷宫探索(后两个测试点无法通过?这里有你想要的答案)
2019-03-03
小白看完都会了!阿里云大师深入拆解Java虚拟机,看完这一篇你就懂了
2019-03-03
VBA之正则表达式(19)-- 相对引用转绝对引用
2019-03-03
巧用VBA统一数字单位
2019-03-03
Transpose实现数组行列转置的限制
2019-03-03