久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

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

          <bdo id='VS1oA'></bdo><ul id='VS1oA'></ul>
        <tfoot id='VS1oA'></tfoot>
      1. C++ 模板類型名迭代器

        C++ template typename iterator(C++ 模板類型名迭代器)

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

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

                <tbody id='SfN1f'></tbody>

                  <bdo id='SfN1f'></bdo><ul id='SfN1f'></ul>
                  本文介紹了C++ 模板類型名迭代器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  考慮以下頭文件:

                  template <typename T> struct tNode
                  {
                      T Data;                      //the data contained within this node
                      list<tNode<T>*> SubNodes;       //a list of tNodes pointers under this tNode
                  
                      tNode(const T& theData)
                      //PRE:  theData is initialized
                      //POST: this->data == theData and this->SubNodes have an initial capacity
                      //      equal to INIT_CAPACITY, it is set to the head of SubNodes
                      {
                          this->Data = theData;
                          SubNodes(INIT_CAPACITY);   //INIT_CAPACITY is 10
                      }
                  
                  };
                  

                  現在考慮來自另一個文件的一行代碼:

                  Now consider a line of code from another file:

                  list<tNode<T>*>::iterator it();  //iterate through the SubNodes
                  

                  編譯器給了我這個錯誤信息:Tree.h:38:17: error: need 'typename' before 'std::list<tNode<T>*>::iterator' 因為 'std::list*>' 是依賴作用域

                  The compiler is giving me this error message: Tree.h:38:17: error: need ‘typename’ before ‘std::list<tNode<T>*>::iterator’ because ‘std::list<tNode<T>*>’ is a dependent scope

                  我不知道為什么編譯器會為此對我大喊大叫.

                  I have no idea why the compiler is yelling at me for this.

                  推薦答案

                  list*>::iterator中,你有一個依賴名稱,即依賴于模板參數的名稱.

                  In list<tNode<T>*>::iterator, you have a dependant name, that is, a name that depends on a template parameter.

                  因此,編譯器無法檢查 list*>(此時它沒有定義),因此它不知道 >list*>::iterator 要么是靜態字段,要么是類型.

                  As such, the compiler can't inspect list<tNode<T>*> (it doesn't have its definition at this point) and so it doesn't know whether list<tNode<T>*>::iterator is either a static field or a type.

                  在這種情況下,編譯器假定它是一個字段,因此在您的情況下它會產生語法錯誤.要解決這個問題,只需在聲明前放置一個 typename 來告訴編譯器它是一個類型:

                  In such a situation, the compiler assumes that it is a field, so in your case it yields a syntax error. To solve the issue, just tell the compiler that it is a type by putting a typename ahead of the declaration:

                  typename list<tNode<T>*>::iterator it
                  

                  這篇關于C++ 模板類型名迭代器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Why do two functions have the same address?(為什么兩個函數的地址相同?)
                  Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復制構造的?)
                  mixing templates with polymorphism(混合模板與多態性)
                  When should I use the keyword quot;typenamequot; when using templates(我什么時候應該使用關鍵字“typename?使用模板時)
                  Dependent name resolution amp; namespace std / Standard Library(依賴名稱解析命名空間 std/標準庫)
                  gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數模板,而 clang 不能)
                  <legend id='xRvEK'><style id='xRvEK'><dir id='xRvEK'><q id='xRvEK'></q></dir></style></legend>
                  <i id='xRvEK'><tr id='xRvEK'><dt id='xRvEK'><q id='xRvEK'><span id='xRvEK'><b id='xRvEK'><form id='xRvEK'><ins id='xRvEK'></ins><ul id='xRvEK'></ul><sub id='xRvEK'></sub></form><legend id='xRvEK'></legend><bdo id='xRvEK'><pre id='xRvEK'><center id='xRvEK'></center></pre></bdo></b><th id='xRvEK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xRvEK'><tfoot id='xRvEK'></tfoot><dl id='xRvEK'><fieldset id='xRvEK'></fieldset></dl></div>
                    <tbody id='xRvEK'></tbody>

                      1. <tfoot id='xRvEK'></tfoot>
                        • <bdo id='xRvEK'></bdo><ul id='xRvEK'></ul>

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

                            主站蜘蛛池模板: 欧美精品区 | 色妞色视频一区二区三区四区 | 超碰在线网站 | 欧美日韩亚洲天堂 | 一级大片免费看 | 毛片aaa | 性巴克成人免费网站 | 黄色片网站在线观看 | 青青草av| 亚洲精品一区二区三区在线观看 | 在线观看日韩av | 一区二区三区久久久 | 日本欧美在线 | 福利一区福利二区 | 免费观看一级一片 | 黄色大片免费观看 | www.com国产| 久久三级视频 | 成人免费公开视频 | 亚洲一区二区欧美 | 免费看一级黄色片 | 天天射综合| 亚洲经典一区二区三区 | 午夜小视频在线观看 | 好色婷婷| 亚洲一区三区 | 国产一级网站 | 久久av中文字幕 | 黄色免费小视频 | 日日狠狠| 日本一区二区三区四区五区 | 国产91久久婷婷一区二区 | 两性免费视频 | 毛片网站大全 | 黑人精品xxx一区一二区 | 综合伊人久久 | 黄色在线免费看 | 夜夜操夜夜操 | 精品一二区 | 蜜桃成人av | 欧美日韩精品一区二区 |