<legend id='viqMk'><style id='viqMk'><dir id='viqMk'><q id='viqMk'></q></dir></style></legend>

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

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

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

        “struct"和“struct"有什么区别?并且缺乏“结构"结构体成员之前的词

        时间:2023-06-30
        <legend id='8VjIN'><style id='8VjIN'><dir id='8VjIN'><q id='8VjIN'></q></dir></style></legend>

          <small id='8VjIN'></small><noframes id='8VjIN'>

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

            <tfoot id='8VjIN'></tfoot>
            • <bdo id='8VjIN'></bdo><ul id='8VjIN'></ul>
                • 本文介绍了“struct"和“struct"有什么区别?并且缺乏“结构"结构体成员之前的词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我必须创建简单的 List 实现.他们想要将 struct 放在 Node 类的成员 next 之前.为什么有struct这个词,没有它有什么区别?

                  I have to create simple List implementation. They guy who wants that put struct before member next of class Node. Why is there a struct word, what would be the difference without it?

                  struct Node{
                      int value;
                      struct Node *next;//what is this struct for?
                  };
                  
                  
                  struct List{
                      struct Node *first, *last;
                  };
                  

                  推荐答案

                  在您的示例中,无需在 next 声明之前使用 struct 关键字.在需要时,它通常被认为是 C 的回退.在 C++ 中,这就足够了:

                  In your example, there is no need to use the struct keyword before the next declaration. It is usually considered a throw-back from C, where it is required. In C++, this would suffice:

                  struct Node{
                      int value;
                      Node *next;
                  };
                  

                  但是,如果您有一个名为 Node 的成员,那么您必须使用 structclass:

                  However, if you had a member called Node, then you would have to use struct or class:

                  struct Node{
                      int Node;
                      struct Node *next; // struct or class required here
                  };
                  

                  对于尚未定义的类型的声明(前向声明),您还需要 classstruct.例如

                  You would also require struct of class for a declaration of a type that is not yet defined (a forward declaration). For example

                  struct Foo {
                      class Bar* bar_; // Bar defined later
                  };
                  

                  我使用 class 来显示它在这种情况下没有区别.

                  where I used class to show it makes no difference in this scenario.

                  这篇关于“struct"和“struct"有什么区别?并且缺乏“结构"结构体成员之前的词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:boost.python 不支持并行? 下一篇:C++ 结构的函数

                  相关文章

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

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

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

                    1. <legend id='sqEas'><style id='sqEas'><dir id='sqEas'><q id='sqEas'></q></dir></style></legend>