<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] ## 概述 名字空間除了系統定義的名字空間之外,還可以自己定義 使用名字空間時用符號`::`指定。 * 不指定名字空間的變量或函數都是當前名字空間下的變量或函數。 * 不定義名字空間的情況下,都屬于**全局名字空間**。 * 同一個名字空間可以定義多次 ## 命名實例 <details> <summary>main.</summary> ``` #include <iostream> using namespace std; namespace na { void print(int n) { //與名字空間nb的函數名相同 cout << "na::print: " << n << endl; } } namespace nb { void print(int n) { //與名字空間na的函數名相同 cout << "nb::print: " << n << endl; } } namespace na // 同一個名字空間可以定義多次 { void print2(int a, int b) { print(a); print(b); } } int main ( ) { na::print(3); // 指定na下的print函數 nb::print(4); // 指定na下的print函數 na::print2(5, 6); // 指定na下的print2函數 return 0; } ``` </details> <br/> ## using 可省略命名空間 使用“using namespace”可以使得后面不需要每次指定名字空間 如 ``` using namespace std; cout<< "hello" //等價于 std::cout << "hello" ``` ## 用別名指定名字空間 ``` namespace A = na::nb::nc; int main ( ) { cout << na::nb::nc::sum(5, 11) << endl; cout << A::sum(6, 12) << endl; return 0; } ``` ## 沒有名字的名字空間 ``` namespace na { namespace { //無名名字空間 int sum(int a, int b) { return a + b; } } int calc(int x, int y) { return sum(x, y); //內部可以調用無名名字空間的變量或函數 } } ``` 外部無法調用 sum
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看