3.3 - [basic.scope] - 【基本.作用域】

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

3 Basic concepts [basic]

3.3 Declarative regions and scopes [basic.scope]

 

3 基本概念 【基本】

3.3 声明区域和作用域 【基本.作用域】

 

Every name is introduced in some portion of program text called a declarative region, which is the largest part of the program in which that name is valid, that is, in which that name may be used as an unqualified name to refer to the same entity. In general, each particular name is valid only within some possibly discontiguous portion of program text called its scope. To determine the scope of a declaration, it is sometimes convenient to refer to the potential scope of a declaration. The scope of a declaration is the same as its potential scope unless the potential scope contains another declaration of the same name. In that case, the potential scope of the declaration in the inner (contained) declarative region is excluded from the scope of the declaration in the outer (containing) declarative region.

 

每个名字都被引入到程序文本中某些被称为声明区域的部分中,声明区域是程序中该名字有效的最广泛区域,也就是说,这个名字在其中可以作为非限定名应用并指代同一个实体。通常情况下,每个特定的名字仅在程序中某些被称为该名字的作用域的不连续区域中有效。为确定一个声明的作用域,通常为方便而提到声明的潜在作用域。声明的作用域与其潜在作用域相同,除非潜在作用域包含相同名字的另一个声明。此时,内部(被包含)的声明区域中声明的潜在作用域被外部(包含的)声明区域中声明的作用域排除。

 

[Example: in

    int j = 24;
    int main()
    {
        int i = j, j;
        j = 42;
    }

the identifier j is declared twice as a name (and used twice). The declarative region of the first j includes the entire example. The potential scope of the first j begins immediately after that j and extends to the end of the program, but its (actual) scope excludes the text between the , and the }. The declarative region of the second declaration of j (the j immediately before the semicolon) includes all the text between { and }, but its potential scope excludes the declaration of i. The scope of the second declaration of j is the same as its potential scope. ]

 

例:如下

    int j = 24;
    int main()
    {
        int i = j, j;
        j = 42;
    }

标识符 j 作为名字被声明两次(并被应用两次)。第一个 j 的声明区域包括整个程序。第一个 j 的潜在作用域从 j 的声明立刻开始,并展开到程序结尾,但其(实际的)作用域排除了从 ,} 之间的文本。第二个 j 声明(紧挨着分号的 j)的声明区域包括从 {} 之间的所有文本,但其潜在作用域不包括 i 的声明。第二个 j 的作用域与其潜在作用域相同。】

 

The names declared by a declaration are introduced into the scope in which the declaration occurs, except that the presence of a friend specifier (11.4), certain uses of the elaborated-type-specifier (3.3.1), and using-directives (7.3.4) alter this general behavior.

 

声明将名字引入该声明发生的作用域中,除非声明具有 friend 限定词(11.4),包含详细类型限定(3.3.1)的特定用法,或使用指令(7.3.4)来改变其一般行为。

 

Given a set of declarations in a single declarative region, each of which specifies the same unqualified name,
  • they shall all refer to the same entity, or all refer to functions and function templates; or
  • exactly one declaration shall declare a class name or enumeration name that is not a typedef name and the other declarations shall all refer to the same object or enumerator, or all refer to functions and function templates; in this case the class name or enumeration name is hidden (3.3.7). [Note: a namespace name or a class template name must be unique in its declarative region (7.3.2, clause 14). ]

[Note: these restrictions apply to the declarative region into which a name is introduced, which is not necessarily the same as the region in which the declaration occurs. In particular, elaborated-type-specifiers (3.3.1) and friend declarations (11.4) may introduce a (possibly not visible) name into an enclosing namespace; these restrictions apply to that region. Local extern declarations (3.5) may introduce a name into the declarative region where the declaration appears and also introduce a (possibly not visible) name into an enclosing namespace; these restrictions apply to both regions. ]

 

若给定某单个声明区域中指定相同非限定名的一组声明,
  • 它们应该全部指代相同实体,或全部指代函数或函数模板;或者
  • 仅能有一个不是 typedef 名字的类名称或枚举名称的声明,而其他声明应该全部指代相同对象或枚举符,或全部指代函数和函数模板;此时类名或枚举名被隐藏(3.3.7)。【注:名字空间名或类模板名在其声明区域中必须唯一(7.3.2,章节 14)。】

【注:这些限制应用于名字被引入其中的声明区域,该区域不必和声明发生的声明区域相同。特别地,详细类型限定词(3.3.1)和友元声明(11.4)能够向包含其的名字空间中引入一个(可能不可见)的名字;这些限制就应用到这个区域。局部外部声明(3.5)能够向其所在的声明区域引入名字,也能向包含它的名字空间中引入(可能不可见的)名字;这些限制对这两个区域都有效。】

 

[Note: the name lookup rules are summarized in 3.4. ]

 

注:3.4 中概述了名字查找规则。】

 

3.3.1 Point of declaration [basic.scope.pdecl]

 

3.3.1 声明点 【基本.作用域.声明点】

 

3.3.2 Local scope [basic.scope.local]

 

3.3.2 局部作用域 【基本.作用域.局部】

 

3.3.3 Function prototype scope [basic.scope.proto]

 

3.3.3 函数原型作用域 【基本.作用域.原型】

 

3.3.4 Function scope [basic.funscope]

 

3.3.4 函数作用域 【基本.函数作用域】

 

3.3.5 Namespace scope [basic.scope.namespace]

 

3.3.5 名字空间作用域 【基本.作用域.名字空间】

 

3.3.6 Class scope [basic.scope.class]

 

3.3.6 类作用域 【基本.作用域.类】

 

3.3.7 Name hiding [basic.scope.hiding]

 

3.3.7 名字隐藏 【基本.作用域.隐藏】

 

PREV [basic.def.odr] | NEXT [basic.scope.pdecl]上一页 【基本.定义.ODR】 | 下一页 【基本.作用域.声明点】
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: kubeadm-basic.images.tar.gz 是一个文件压缩包,其中包含了运行 Kubernetes 集群所需的基本镜像。kubeadm 是 Kubernetes 的安装工具之一,它可以快速地在多台主机上部署一个 Kubernetes 集群。 在使用 kubeadm 安装 Kubernetes 集群时,需要提前下载一些基础镜像,并将它们保存为 kubeadm-basic.images.tar.gz 文件。这样在安装过程中就可以直接使用这个文件,而不需要再次下载这些镜像,加快安装速度。 kubeadm-basic.images.tar.gz 中包含了一些核心的镜像,如 kube-apiserver、kube-controller-manager、kube-scheduler 等,它们是 Kubernetes 集群的核心组件。此外,还包含了一些常用的镜像,如 etcd、kube-proxy、coredns 等。这些镜像由 Kubernetes 官方维护,确保了其稳定性和可靠性。 使用 kubeadm 安装 Kubernetes 集群时,可以通过以下步骤使用 kubeadm-basic.images.tar.gz 文件: 1. 首先,将 kubeadm-basic.images.tar.gz 文件传输到所有的集群节点上,可以使用 scp 或者其他文件传输工具。 2. 然后,在每个节点上将 kubeadm-basic.images.tar.gz 文件解压缩。 3. 接下来,可以使用 Docker 命令将解压后的镜像加载到 Docker 引擎中,例如:`docker load -i kubeadm-basic.images.tar.gz`。 4. 等待镜像加载完成后,就可以使用 kubeadm 工具进行 Kubernetes 集群的初始化和安装了。 通过使用 kubeadm-basic.images.tar.gz 文件,可以避免多次下载镜像,从而加快了 Kubernetes 集群的安装速度,特别适用于离线环境或者带宽有限的场景。同时,也可以方便地管理和传递这些基础镜像,确保在不同的部署中使用相同的镜像版本,增加集群的一致性和可维护性。 ### 回答2: kubeadm-basic.images.tar.gz是一个压缩文件,它包含了kubeadm工具所需的基本镜像。kubeadm是Kubernetes提供的用于初始化集群的工具,它需要一些预先准备好的镜像来保证集群的正常运行。 在Kubernetes集群中,每个节点上都需要存在各种镜像,这些镜像用于运行不同的组件和服务。kubeadm-basic.images.tar.gz中的镜像是一组Kubernetes所需的最基本的镜像,包括kube-apiserver、kube-controller-manager、kube-scheduler以及etcd等。这些镜像是集群所必需的核心组件,没有它们集群将无法正常运行。 使用kubeadm-basic.images.tar.gz可以方便地在各个节点上部署Kubernetes集群所需的镜像。通过将该压缩文件解压缩并导入到各个节点的Docker或容器运行时中,即可在每个节点上完成镜像的安装和准备工作。 在进行Kubernetes集群的初始化过程中,kubeadm会根据所需的组件和服务选择并下载相应的镜像。但是,由于网络等原因可能导致下载镜像的速度较慢或失败。使用kubeadm-basic.images.tar.gz可以避免这样的问题,减少集群初始化的时间,并且能够在离线环境中方便地部署Kubernetes集群。 总而言之,kubeadm-basic.images.tar.gz是一个方便快捷的工具,它提供了Kubernetes所需的基本镜像,可以简化集群的初始化过程,并且能够在离线环境中保证集群的正常运行。 ### 回答3: kubeadm-basic.images.tar.gz是一个用于Kubernetes集群安装和部署的镜像文件。Kubernetes是一个开源的容器编排平台,可以帮助用户快速、简便地部署、管理和扩展容器化应用程序。 kubeadm是Kubernetes的一个重要组件,用于初始化和设置Kubernetes集群的工具。它可以帮助用户在不同的计算机节点上快速部署和配置Kubernetes集群,并提供了一些标准化的操作和命令,简化了集群的安装和维护过程。 kubeadm-basic.images.tar.gz是一个经过压缩的镜像文件,其中包含了Kubernetes集群安装所需的基本镜像。这些镜像包括了Kubernetes的核心组件,如kube-apiserver、kube-controller-manager、kube-scheduler等,以及其他常用的工具和插件,如CoreDNS、kube-proxy等。通过使用这个镜像文件,用户可以在没有网络连接的环境下,快速部署一个基本的Kubernetes集群,并且省去了从互联网上下载镜像的麻烦。 对于需要频繁进行Kubernetes集群部署和测试的用户来说,kubeadm-basic.images.tar.gz可以提供更加高效和可靠的安装方式。同时,用户也可以基于这个镜像文件进行定制,将自己所需的镜像添加到其中,以满足特定的应用场景和需求。 总之,kubeadm-basic.images.tar.gz是一个方便快速部署Kubernetes集群的镜像文件,可以帮助用户简化集群的安装和部署过程,提高工作效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值