c++ - 为什么要使用 typedef 来声明结构?

标签 c++

<分区>

Possible Duplicate:
Difference between 'struct' and 'typedef struct' in C++?

有区别吗

typedef struct{
....
} mystruct;

struct mystruct{
....
};

?

最佳答案

在 C 中,声明结构的语法是 struct mystruct var;,因此开发人员通常会键入定义一个匿名结构,以使声明像 mystruct var; 一样简单。 C++ 允许您在不使用 struct 关键字的情况下定义结构,因此 typedef 的使用频率较低。

关于c++ - 为什么要使用 typedef 来声明结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6818199/

相关文章:

android - 将 tess-two(Tesseract Tools for Android)库集成到 Android 工作室并构建 ndk

c++ - 为什么静态 ofstream 不起作用

c++ - 我在解释 N4140 的§8.5.3/5 段中的要点 (5.2.1.1) 时遇到了一些困难

c++ - Boost 库中的网络是如何实现的

c++ - 使用已删除函数 - std::atomic

c++ - 强制执行 Visual Studio 异常处理模式

c++ - C++ 中的 std::thread 与 Go 语言中的 goroutine?

C++ 模板错误

c++ - 有没有办法在 QMap 值中设置一个类?

c++ - 根据常量整数字段设置数组字段的长度