C++ 语言定义对 static 关键字的范围有何看法?

What does C++ language definition say about the extent of the static keyword?

在 C++ 中,如果我有 class:

class Example {
  static int s_One, s_Two;

  ...
};

语言是否明确定义s_Two也是静态的?

换句话说,static 关键字 extent 是 int 所到之处,还是像 * 一样只适用于一个变量?

根据 C++ 17 标准(10 个声明)

2 形式为

的简单声明或 nodeclspec 函数声明
attribute-specifier-seqopt decl-specifier-seqopt init-declarator-listopt ;

和(10.1 说明符):

1 The specifiers that can be used in a declaration are

decl-specifier:
    storage-class-specifier
    ...

所以在这个声明中

static int s_One, s_Two;

decl-specifier-seq包含两个decl-specifiersstatic(存储class说明符)和int。因此存储 class 说明符 static 描述了 init-declarator-list s_Ones_Two.

中的两个变量

是的,它适用于该声明中的每个名称:

[dcl.stc]/1: [..] At most one storage-class-specifier shall appear in a given decl-specifier-seq [..] The storage-class-specifier applies to the name declared by each init-declarator in the list [..]