久久久久久久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++ 模板類型名迭代器的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  考慮以下頭文件:

                  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
                      }
                  
                  };
                  

                  現(xiàn)在考慮來自另一個(gè)文件的一行代碼:

                  Now consider a line of code from another file:

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

                  編譯器給了我這個(gè)錯(cuò)誤信息:Tree.h:38:17: error: need 'typename' before 'std::list<tNode<T>*>::iterator' 因?yàn)?'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

                  我不知道為什么編譯器會(huì)為此對(duì)我大喊大叫.

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

                  推薦答案

                  list*>::iterator中,你有一個(gè)依賴名稱,即依賴于模板參數(shù)的名稱.

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

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

                  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.

                  在這種情況下,編譯器假定它是一個(gè)字段,因此在您的情況下它會(huì)產(chǎn)生語(yǔ)法錯(cuò)誤.要解決這個(gè)問題,只需在聲明前放置一個(gè) typename 來告訴編譯器它是一個(gè)類型:

                  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
                  

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

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

                  相關(guān)文檔推薦

                  Why do two functions have the same address?(為什么兩個(gè)函數(shù)的地址相同?)
                  Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復(fù)制構(gòu)造的?)
                  mixing templates with polymorphism(混合模板與多態(tài)性)
                  When should I use the keyword quot;typenamequot; when using templates(我什么時(shí)候應(yīng)該使用關(guān)鍵字“typename?使用模板時(shí))
                  Dependent name resolution amp; namespace std / Standard Library(依賴名稱解析命名空間 std/標(biāo)準(zhǔn)庫(kù))
                  gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數(shù)模板,而 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'>

                            主站蜘蛛池模板: 91中文字幕在线 | 韩国久久 | www97影院 | 九九热久久免费视频 | 手机看片1 | 久久99精品国产麻豆婷婷 | 午夜久久久久久久久久一区二区 | 精品久| 免费成人在线网 | 国产精品99久久久久久宅男 | 国产精品永久在线观看 | 浴室洗澡偷拍一区二区 | 视频一区 亚洲 | 欧美精品在线观看 | 国产亚洲精品美女久久久久久久久久 | 久久精品国产一区 | 亚洲一区二区 | 国产成人一区二区 | 久久久www成人免费精品张筱雨 | 欧美日韩精品一区 | 91精品国产高清一区二区三区 | 国产精品美女一区二区三区 | 国外成人在线视频 | 91免费看片 | 午夜丁香视频在线观看 | 国产91精品久久久久久久网曝门 | 中文字幕乱码一区二区三区 | 国产精品毛片一区二区在线看 | 日韩精品免费视频 | 91成人精品 | 五月婷婷婷 | 久在线| 在线播放亚洲 | 一本综合久久 | 国产精品成人免费 | 亚洲一区综合 | 天天夜天天操 | 国产高清视频在线观看播放 | 亚洲免费在线观看 | 亚洲狠狠 | 国产一区91在线 |