次の方法で共有


Initializing Bases and Members

An object of a derived class is made up of a component that represents each base class and a component that is unique to the particular class. Objects of classes that have member objects may also contain instances of other classes. This section describes how these component objects are initialized when an object of the class type is created.

To perform the initialization, a list of initializers separated by commas is used. Each initializer consists of an identifier for a base class or a data member of the class being constructed, followed by an expression list in parentheses.

A() : MyBase(200, "A1"), value1(100), value2(100)

This syntax, used in constructors, is described more fully in the next section, Initializing Member Objects, and in Initializing Base Classes.

See Also

Concepts

Initialization Using Special Member Functions