
C++ typedef struct v.s. struct
发布日期:2021-05-06 19:47:44
浏览次数:26
分类:原创文章
本文共 927 字,大约阅读时间需要 3 分钟。
C++ typedef struct v.s. struct
typedef struct v.s. struct
在C語言中,定義完一個struct之後,我們通常還會加上typedef
。這樣以後用到struct xxx
時,我們就能用yyy
代指,而不用老是加上struct
這個關鍵字:
struct xxx { ...};typedef struct xxx yyy;
而在C++中是怎麼回事呢?摘自:
In C++, there is no difference between 'struct' and 'typedef struct' because, in C++, all struct/union/enum/class declarations act like they are implicitly typedef'ed, as long as the name is not hidden by another declaration with the same name.
在C++中,宣告struct
時就隱性地為它typedef
過了。所以我們不需要使用typedef xxx yyy
,就能直接不帶struct
關鍵字地使用該struct
。
在TensorRT/samples/common/argsParser.h
中,定義完Args
這個結構體後,不需要先typedef
,就能直接在parseArgs
函數裡不帶struct
關鍵字地使用它:
struct Args{ bool runInInt8{ false}; bool runInFp16{ false}; bool help{ false}; int useDLACore{ -1}; int batch{ 1}; std::vector<std::string> dataDirs; bool useILoop{ false};};inline bool parseArgs(Args& args, int argc, char* argv[]){ //...}
參考連結
发表评论
最新留言
很好
[***.229.124.182]2025年04月07日 01时07分33秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
关于mysql卸载问题
2019-03-04
血色先锋队
2019-03-04
21年寒假第一周周练/HDU1176:免费馅饼
2019-03-04
win10系统安装配置Go环境包(第0章)
2019-03-04
K8S实战之理解Pod
2019-03-04
Prime Ring Problem-dfs
2019-03-04
k8s实战之理解helm
2019-03-04
历届试题 日期问题
2019-03-04
如何搭建MFS分布式文件系统
2019-03-04
搭建samba服务器
2019-03-04
微信小程序开发工具
2019-03-04
python第三章
2019-03-04
五一快乐训练
2019-03-04
JS中的对象和函数基础
2019-03-04
第三章:数据查询语言DQL-自连接查询的场景及使用
2019-03-04
第六章:多线程-线程安全问题
2019-03-04
Java: 错误: 不支持发行版本 5
2019-03-04
大数据之Flume:Flume监控端口数据官方案例
2019-03-04
大数据之Flume:Flume拓扑结构
2019-03-04