3.3.6 - [basic.scope.class] - 【基本.作用域.类】

博客内容主要是关于文章使用的版权声明,包括禁止转载、重新出版发布,要求下载 24 小时内删除,禁止用于商业目的等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

请不要转载本文;请不要以任何形式重新出版,发布本文;请在下载本文 24 小时内将其删除;禁止将本文用于商业目的。

3 Basic concepts [basic]

3.3 Declarative regions and scopes [basic.scope]
3.3.6 Class scope [basic.scope.class]

 

3 基本概念 【基本】

3.3 定义区域和作用域 【基本.作用域】
3.3.6 类作用域 【基本.作用域.类】

 

The following rules describe the scope of names declared in classes.
  1. The potential scope of a name declared in a class consists not only of the declarative region following the name's declarator, but also of all function bodies, default arguments, and constructor ctor-initializers in that class (including such things in nested classes).
  2. A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S. No diagnostic is required for a violation of this rule.
  3. If reordering member declarations in a class yields an alternate valid program under 1 and 2, the program is ill-formed, no diagnostic is required.
  4. A name declared within a member function hides a declaration of the same whose scope extends to or past the end of the member function's class.
  5. The potential scope of a declaration that extends to or past the end of a class definition also extends to the regions defined by its member definitions, even if the members are defined lexically outside the class (this includes static data member definitions, nested class definitions, member function definitions (including the member function body and, for constructor functions (12.1), the ctor-initializer (12.6.2)) and any portion of the declarator part of such definitions which follows the identifier, including a parameter-declaration-clause and any default arguments (8.3.6). [Example:

        typedef int  c;
        enum { i = 1 };

        class X {

            char  v[i];                     // error: i refers to ::i
                                            // but when reevaluated is X::i
            int  f() { return sizeof(c); }  // OK: X::c
            char  c;
            enum { i = 2 };
        };

        typedef char*  T;
        struct Y {
            T  a;                           //
    error: T refers to ::T
                                            //
    but when reevaluated is Y::T
            typedef long T;
            T  b;
        };

        typedef int I;
        class D {
            typedef I I;                    //
    error, even though no reordering involved
        };

    --end example]

 
如下规则描述了在类中声明的名字的作用域。
  1. 在类中声明的名字的潜在作用域不仅包括其声明符后面的声明区域,还包括该类的所有函数体,默认参数,以及构造函数的 ctor-初始化符,(包括嵌套类的相应东西)。
  2. 在类 S 中应用的名字 N 在其语境中所指代的声明,以及当 S 的作用域完成时所重新评估得到的声明应当相同。违反此条规则不需要诊断。
  3. 如果在规则 1 和 2 下,对某个类的成员声明重新安排会产生不同的合法程序,则程序是病态形式的,不需要诊断。
  4. 在成员函数中声明的名字,将隐藏作用域为此成员函数所在类之外,或结尾之后的相同名字的声明。
  5. 在类定义外部或之后的声明的潜在作用域同样在该类的成员定义之外,而不管这些成员在词法上是否定义在类(这些成员包括静态数据成员定义,嵌套类定义,成员函数定义(包括成员函数体和构造函数(12.1)的 ctor-初始化符(12.6.2)) ,或任何在该标识符后面的声明符部分,包括参数-声明-子句以及任何默认自变量(8.3.6)的外面。【例:

        typedef int  c;
        enum { i = 1 };

        class X {

            char  v[i];                     // 错误:i 指代 ::i
                                            // 但当进行重新评估后将为 X::i
            int  f() { return sizeof(c); }  // 正确: X::c
            char  c;
            enum { i = 2 };
        };

        typedef char*  T;
        struct Y {
            T  a;                           //
    错误:T 指代 ::T
                                            //
    但当进行重新评估后将为 Y::T
            typedef long T;
            T  b;
        };

        typedef int I;
        class D {
            typedef I I;                    //
    错误,即使没有对其重新安排
        };

    --例完

 

The name of a class member shall only be used as follows:
  • in the scope of its class (as described above) or a class derived (clause 10) from its class,
  • after the . operator applied to an expression of the type of its class (5.2.5) or class derived from its class,
  • after the -> operator applied to a pointer to an object of its class (5.2.5) or a class derived from its class,
  • after the :: scope resolution operator (5.1) applied to the name of its class or a class derived from its class.

 

类成员的名称仅能被按照下列情况使用:
  • 在其类的作用域(如上所述)或某派生(章节 10)自该类的类的作用域,
  • 在应用到该类,或派生自该类的类型的表达式(5.2.5)上的 . 运算符后面,
  • 在应用到指向该类,或派生自该类的类对象的指针(5.2.5)上的 -> 运算符后面,
  • 在应用到该类,或派生自该类的类名称上的 :: 作用域解析运算符(5.1)后面。

 

PREV [basic.scope.namespace] | NEXT [basic.scope.hiding]上一页 【基本.作用域.名字空间】 | 下一页 【基本.作用域.隐藏】
<think>好的,用户现在提供了一个文件列表,询问应该下载哪个文件。首先,我需要分析用户的需求。根据之前的对话历史,用户之前询问过如何下载Hadoop的winutils,用于Spark在Windows环境下的支持。现在用户面对的是Apache Hadoop官方下载页面中的文件列表,需要帮助确定哪个文件适合下载。 首先,用户可能是在寻找Hadoop的预编译二进制包,以便在Windows上使用,或者是为了获取winutils.exe和hadoop.dll文件。但根据之前的回复,Hadoop官方并没有直接提供Windows的二进制包,而是需要从社区资源获取。但用户现在看到的可能是官方发布的不同版本文件,需要明确每个文件的用途。 接下来,我需要逐一查看用户提供的文件列表,并解释每个文件的作用。例如,带有“aarch64”的是针对ARM架构的,可能不适合大多数用户的x86环境;“src”是源代码,需要编译;“site”可能是文档;“rat.txt”可能和许可证检查有关。用户需要的应该是通用的Hadoop二进制包,即hadoop-3.3.6.tar.gz,因为它适用于常见的x86架构,并且是预编译的二进制版本。 同时,用户可能需要验证文件的完整性,所以需要解释.asc和.sha512文件的作用,指导用户如何验证下载的文件是否完整且未被篡改。此外,用户可能之前遇到的问题是找不到winutils,所以需要提醒用户,即使下载了官方的tar.gz文件,可能仍然需要从其他渠道获取winutils,因为官方包中可能不包含Windows所需的这些文件。 最后,总结建议用户下载hadoop-3.3.6.tar.gz,并说明原因,同时提醒版本兼容性和后续步骤,比如设置环境变量或获取winutils。需要确保回答清晰,步骤明确,帮助用户解决问题。</think>### **文件分析及下载建议** 根据你提供的 Apache Hadoop 3.3.6 文件列表,以下是关键文件的功能说明和下载优先级建议: --- #### **1. 核心文件选择(必选)** - **`hadoop-3.3.6.tar.gz`** - **用途**:适用于 **x86/x64 架构** 的 Hadoop 官方预编译二进制包(Linux/Unix 环境)。 - **推荐场景**: - 需要直接部署 Hadoop 集群 - 需通过解压获取 `bin` 目录(但注意:官方包中的 `bin` 目录可能不包含 `winutils.exe` 等 Windows 工具) - **下载优先级**:⭐️⭐️⭐️⭐️⭐️ --- #### **2. 其他文件说明(按需选择)** | 文件名 | 用途 | 是否下载建议 | |--------|------|--------------| | `hadoop-3.3.6-aarch64.tar.gz` | **ARM 架构**(如苹果 M 系列芯片)的 Hadoop 二进制包 | 仅 ARM 设备用户需下载 | | `hadoop-3.3.6-src.tar.gz` | Hadoop 源代码(需自行编译) | 开发者或定制化场景 | | `hadoop-3.3.6-site.tar.gz` | 官方文档(HTML/PDF 格式) | 需查阅离线文档时下载 | | `hadoop-3.3.6-rat.txt` | Apache RAT(许可证审核)报告 | 无需下载 | --- #### **3. 验证文件(可选)** 所有 `.asc`(PGP 签名)和 `.sha512`(哈希校验)文件用于验证下载文件的完整性和真实性。 - **验证步骤示例**: ```bash # 校验 SHA512 哈希(Linux/macOS) shasum -a 512 hadoop-3.3.6.tar.gz # 对比输出与 hadoop-3.3.6.tar.gz.sha512 中的值 # 验证 PGP 签名(需导入 Apache 公钥) gpg --verify hadoop-3.3.6.tar.gz.asc ``` --- ### **注意事项** 1. **Windows 用户特别注意**: - 官方 `hadoop-3.3.6.tar.gz` **不包含 `winutils.exe` 或 `hadoop.dll`**(需从社区仓库单独获取,如 GitHub/Gitee)。 2. **版本兼容性**: - 确保所选 Hadoop 版本与 Spark 或其他依赖框架兼容(例如 Spark 3.5.5 需 Hadoop 3.3.6)。 --- ### **总结** - **推荐下载文件**:`hadoop-3.3.6.tar.gz`(通用 x86/x64 环境)。 - **补充操作**: - 若需 Windows 支持工具(如 `winutils.exe`),仍需通过社区仓库([GitHub](https://github.com/cdarlint/winutils)/[Gitee](https://gitee.com/mirrors/winutils))下载。 - 配置 `HADOOP_HOME` 环境变量指向解压后的目录。 如需进一步帮助(如验证步骤或配置说明),请提供具体使用场景或报错信息。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值