<bdo id='PqHzI'></bdo><ul id='PqHzI'></ul>
  1. <small id='PqHzI'></small><noframes id='PqHzI'>

    <legend id='PqHzI'><style id='PqHzI'><dir id='PqHzI'><q id='PqHzI'></q></dir></style></legend>
      <i id='PqHzI'><tr id='PqHzI'><dt id='PqHzI'><q id='PqHzI'><span id='PqHzI'><b id='PqHzI'><form id='PqHzI'><ins id='PqHzI'></ins><ul id='PqHzI'></ul><sub id='PqHzI'></sub></form><legend id='PqHzI'></legend><bdo id='PqHzI'><pre id='PqHzI'><center id='PqHzI'></center></pre></bdo></b><th id='PqHzI'></th></span></q></dt></tr></i><div id='PqHzI'><tfoot id='PqHzI'></tfoot><dl id='PqHzI'><fieldset id='PqHzI'></fieldset></dl></div>
    1. <tfoot id='PqHzI'></tfoot>
    2. 文件作用域和全局作用域的区别

      Difference between File Scope and Global Scope(文件作用域和全局作用域的区别)
      • <bdo id='3kLnp'></bdo><ul id='3kLnp'></ul>
          <tbody id='3kLnp'></tbody>

            <legend id='3kLnp'><style id='3kLnp'><dir id='3kLnp'><q id='3kLnp'></q></dir></style></legend>
          • <small id='3kLnp'></small><noframes id='3kLnp'>

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

                <tfoot id='3kLnp'></tfoot>
                本文介绍了文件作用域和全局作用域的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我是一名学生,我对 C 和 C++ 中的全局和文件范围变量感到困惑.两种观点有什么不同吗?如果是,请详细说明.

                I am a student and I am confused about global and file scope variables in C and C++. Is there any difference in both perspectives? If yes, please explain in detail.

                推荐答案

                具有文件作用域的变量可以被单个文件中的任何函数或块访问.要声明文件范围的变量,只需在块外声明一个变量(与全局变量相同),但使用 static 关键字.

                A variable with file scope can be accessed by any function or block within a single file. To declare a file scoped variable, simply declare a variable outside of a block (same as a global variable) but use the static keyword.

                static int nValue; // file scoped variable
                float fValue; // global variable
                
                int main()
                {
                    double dValue; // local variable
                }
                

                文件作用域变量的作用与全局变量完全一样,只是它们的使用仅限于声明它们的文件.

                File scoped variables act exactly like global variables, except their use is restricted to the file in which they are declared.

                这篇关于文件作用域和全局作用域的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Is Type(::x); valid?(是类型(::x);有效的?)
                Difference between an inline function and static inline function(内联函数和静态内联函数的区别)
                Compilation fails randomly: quot;cannot open program databasequot;(编译随机失败:“无法打开程序数据库)
                Too many initializers error for a simple array in bcc32(bcc32 中的简单数组的初始值设定项过多错误)
                No Member named stoi in namespace std(命名空间 std 中没有名为 stoi 的成员)
                Error using a constexpr as a template parameter within the same class(在同一个类中使用 constexpr 作为模板参数时出错)
              1. <small id='nmDOF'></small><noframes id='nmDOF'>

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

                • <tfoot id='nmDOF'></tfoot>
                    <tbody id='nmDOF'></tbody>

                      • <bdo id='nmDOF'></bdo><ul id='nmDOF'></ul>

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