C++ 中 class 的 "member" 究竟是什么?

What exactly is a "member" of a class in C++?

我是 C++ 新手,有 Java 和 Python 方面的经验。我试着在Stack上搜索了一段时间这个问题,但没有找到任何类似的问题(虽然这可能是因为我对C++的粗略了解)。

我一直在阅读 C++ 入门书,直到我偶然发现 C++ 中的 "members" 个 classes。我可以从 Java 理解 class 的概念,但我不确定 "member" 是什么。

成员只是 class 的一个实例吗?如果是这样,为什么 class 中的变量似乎也被视为成员(在 Primer 中,一本书的 class 的 ISBN 号被视为成员)?

谁能给出 C++ 中 "member" 的一般定义?

成员定义为class.

中的变量和函数

在 class 中定义的变量有时称为成员变量。同样,函数也可以称为成员函数。除此之外,就没什么了。

成员是属于 class 的某个实体。

如果 class 有一个函数,这是一个成员函数 - 您可能知道它是 "a method"。
如果 class 有一个变量,这是一个成员变量——你可能知道它是 "a property".

int a;
void f () {};

class A{
 int m_A;
  void m_F(){}
}

a是一个全局变量。
f 是一个全局函数。
m_A是classA的成员变量或"property"。
m_F 是 class A 的成员函数或 "method"。

我想 google 搜索应该有效,因为我只搜索了 5 秒:

Classes are an expanded concept of data structures: like data structures, they can contain data members, but they can also contain functions as members.

您可以在此处查看更完整的定义:http://www.cplusplus.com/doc/tutorial/classes/

简而言之,数据成员(即 class 的变量)和函数都是 class 的成员。

据我记忆,java个成员完全一样

根据 C++ 标准(9.2 Class 成员)

1 The member-specification in a class definition declares the full set of members of the class; no member can be added elsewhere. Members of a class are data members, member functions (9.3), nested types, and enumerators. Data members and member functions are static or non-static; see 9.4. Nested types are classes (9.1, 9.7) and enumerations (7.2) defined in the class, and arbitrary types declared as members by use of a typedef declaration (7.1.3). The enumerators of an unscoped enumeration (7.2) defined in the class are members of the class. Except when used to declare friends (11.3) or to introduce the name of a member of a base class into a derived class (7.3.3), member-declarations declare members of the class, and each such member-declaration shall declare at least one member name of the class. A member shall not be declared twice in the member-specification, except that a nested class or member class template can be declared and then later defined, and except that an enumeration can be introduced with an opaque-enum-declaration and later redeclared with an enum-specifier.

另外 class 个成员是

using-declaration
static_assert-declaration
template-declaration
alias-declaration