<i id='pDEZW'><tr id='pDEZW'><dt id='pDEZW'><q id='pDEZW'><span id='pDEZW'><b id='pDEZW'><form id='pDEZW'><ins id='pDEZW'></ins><ul id='pDEZW'></ul><sub id='pDEZW'></sub></form><legend id='pDEZW'></legend><bdo id='pDEZW'><pre id='pDEZW'><center id='pDEZW'></center></pre></bdo></b><th id='pDEZW'></th></span></q></dt></tr></i><div id='pDEZW'><tfoot id='pDEZW'></tfoot><dl id='pDEZW'><fieldset id='pDEZW'></fieldset></dl></div>

<small id='pDEZW'></small><noframes id='pDEZW'>

    • <bdo id='pDEZW'></bdo><ul id='pDEZW'></ul>
    1. <legend id='pDEZW'><style id='pDEZW'><dir id='pDEZW'><q id='pDEZW'></q></dir></style></legend>

        <tfoot id='pDEZW'></tfoot>

        在 C++ 中的变量声明中使用 struct 关键字

        using struct keyword in variable declaration in C++(在 C++ 中的变量声明中使用 struct 关键字)
          <tbody id='TpkNS'></tbody>

          <i id='TpkNS'><tr id='TpkNS'><dt id='TpkNS'><q id='TpkNS'><span id='TpkNS'><b id='TpkNS'><form id='TpkNS'><ins id='TpkNS'></ins><ul id='TpkNS'></ul><sub id='TpkNS'></sub></form><legend id='TpkNS'></legend><bdo id='TpkNS'><pre id='TpkNS'><center id='TpkNS'></center></pre></bdo></b><th id='TpkNS'></th></span></q></dt></tr></i><div id='TpkNS'><tfoot id='TpkNS'></tfoot><dl id='TpkNS'><fieldset id='TpkNS'></fieldset></dl></div>
          <legend id='TpkNS'><style id='TpkNS'><dir id='TpkNS'><q id='TpkNS'></q></dir></style></legend>

                • <bdo id='TpkNS'></bdo><ul id='TpkNS'></ul>
                • <tfoot id='TpkNS'></tfoot>

                  <small id='TpkNS'></small><noframes id='TpkNS'>

                  本文介绍了在 C++ 中的变量声明中使用 struct 关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我感觉这可能与 C 语法有关,但我的编程生涯是从 C++ 开始的,所以我不确定.

                  I have a feeling this may be related to C syntax, but I started my programming life with C++ so I am not sure.

                  基本上我见过这个:

                  struct tm t;
                  memset( &t, 0, sizeof(struct tm) );
                  

                  我对这种语法有点困惑,因为通常我希望上面的内容看起来像这样:

                  I am a bit confused with this syntax, as normally I would expect the above to instead look like this:

                  tm t;
                  memset( &t, 0, sizeof(tm) );
                  

                  两者有什么区别,为什么用前者代替?

                  What is the difference between the two, and why is the former used instead?

                  我所指的结构tmwchar.h中,定义如下:

                  The structure tm that I am referring to is in wchar.h, and the definition is as follows:

                  struct tm {
                          int tm_sec;     /* seconds after the minute - [0,59] */
                          int tm_min;     /* minutes after the hour - [0,59] */
                          int tm_hour;    /* hours since midnight - [0,23] */
                          int tm_mday;    /* day of the month - [1,31] */
                          int tm_mon;     /* months since January - [0,11] */
                          int tm_year;    /* years since 1900 */
                          int tm_wday;    /* days since Sunday - [0,6] */
                          int tm_yday;    /* days since January 1 - [0,365] */
                          int tm_isdst;   /* daylight savings time flag */
                          };
                  

                  推荐答案

                  简单的答案是 struct 关键字的存在来限制标识符 tm 的查找仅用户定义的类类型.它可能是为了与 C 兼容,在需要的地方.

                  The simple answer is that the struct keyword there is present to restrict the lookup of the identifier tm to only user defined class types. It is probably left for compatibility with C, where it is required.

                  与其他人所说的相反,没有 auto-typedef 这样的东西,C 和 C++ 在如何管理用户定义类型的标识符方面也没有区别.唯一的区别在于查找.

                  Contrary to what others say, there is no such thing as auto-typedef, nor do C and C++ differ with respect to how the identifiers for user defined types are managed. The only difference is in lookup.

                  您可以在此处

                  这篇关于在 C++ 中的变量声明中使用 struct 关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to print vector#39;s data(如何打印矢量的数据)
                  Visual C++ appends 0xCC (int3) bytes at the end of functions(Visual C++ 在函数末尾附加 0xCC (int3) 字节)
                  How to use a variable inside a _T wrapper?(如何在 _T 包装器中使用变量?)
                  MSVC++ warning flags(MSVC++ 警告标志)
                  How to read file which contains uxxxx in vc++(如何在vc++中读取包含uxxxx的文件)
                  stack overflow error in C++ program(C++程序中的堆栈溢出错误)

                    <legend id='CadE8'><style id='CadE8'><dir id='CadE8'><q id='CadE8'></q></dir></style></legend>
                      <tbody id='CadE8'></tbody>

                      <small id='CadE8'></small><noframes id='CadE8'>

                          <bdo id='CadE8'></bdo><ul id='CadE8'></ul>

                        • <tfoot id='CadE8'></tfoot>

                          <i id='CadE8'><tr id='CadE8'><dt id='CadE8'><q id='CadE8'><span id='CadE8'><b id='CadE8'><form id='CadE8'><ins id='CadE8'></ins><ul id='CadE8'></ul><sub id='CadE8'></sub></form><legend id='CadE8'></legend><bdo id='CadE8'><pre id='CadE8'><center id='CadE8'></center></pre></bdo></b><th id='CadE8'></th></span></q></dt></tr></i><div id='CadE8'><tfoot id='CadE8'></tfoot><dl id='CadE8'><fieldset id='CadE8'></fieldset></dl></div>