14.7.six Digital, shut, override, and abstract accessors

14.7.six Digital, shut, override, and abstract accessors

fourteen.7.4 Immediately used qualities

An immediately implemented assets (otherwise auto-possessions to possess brief), is a low-abstract, non-extern assets that have semicolon-simply accessor bodies. Auto-qualities shall features a score accessor that will optionally enjoys matchbox an effective place accessor.

Whenever a property try given because an immediately adopted assets, a hidden support industry is actually immediately designed for the property, while the accessors try accompanied to read through away from and you can produce so you’re able to you to definitely backing community. The invisible backing field is unreachable, it could be comprehend and you will written only through the automatically accompanied possessions accessors, actually when you look at the with style of. Should your car-possessions does not have any set accessor, the fresh new backing industry is recognized as readonly (§fourteen.5.3). Just like good readonly community, an excellent getter-just vehicles-possessions can certainly be allotted to in the human body of an excellent constructor of your enclosing classification. Such a project assigns right to the understand-simply backing realm of the home.

fourteen.eight.5 Access to

In the event that a keen accessor have an enthusiastic accessor_modifier, this new entry to website name (§seven.5.3) of accessor is determined making use of the declared the means to access of accessor_modifier. In the event that an accessor does not have an accessor_modifier, the new accessibility domain name of the accessor is set on the stated the means to access of the house otherwise indexer.

The presence of a keen accessor_modifier never impacts associate search (§eleven.5) otherwise overload resolution (§eleven.six.4). This new modifiers to the possessions otherwise indexer constantly figure out which assets or indexer will, long lasting perspective of your own availableness.

Immediately following a certain property or indexer might have been picked, brand new accessibility domain names of certain accessors in it are widely used to determine if one need holds true:

  • In the event your usage is just as a respect (§eleven.dos.2), new get accessor shall can be found and get available.
  • If your utilize is really as the prospective off a simple assignment (§.2), this new put accessor should exist and be obtainable.
  • In case the usage is as the mark of substance assignment (§.3), or as address of your own ++ or — workers (§11.seven.fourteen, §eleven.8.6), both the rating accessors plus the put accessor should can be found and you will be around.

Example: Throughout the after the example, the property A.Text is hidden of the property B.Text , despite contexts where just the lay accessor is known as. On the other hand, the home B.Number is not open to group Yards , therefore, the accessible assets Good.Matter is employed rather.

An accessor which is used to apply an interface should maybe not enjoys a keen accessor_modifier. If only one to accessor can be used to apply a program, the other accessor could be declared that have an enthusiastic accessor_modifier:

A virtual possessions statement specifies your accessors of the property is actually digital. The fresh new digital modifier applies to the low-individual accessors regarding a house. Whenever an accessor out of a virtual possessions has got the private accessor_modifier, the non-public accessor is actually implicitly maybe not digital.

A conceptual assets report determine your accessors of the home is virtual, but doesn’t offer an actual utilization of this new accessors. Rather, non-conceptual derived kinds are required to provide their own implementation having the fresh new accessors from the overriding the home. Once the an accessor to own an abstract assets declaration will bring no actual implementation, their accessor_human anatomy simply includes a great semicolon. An abstract possessions will not have an exclusive accessor.

A home report filled with both abstract and you may override modifiers determine that home is conceptual and you can overrides a base assets. The newest accessors of these a home are also conceptual.

Conceptual possessions declarations are only allowed for the abstract kinds (§fourteen.2.2.2). The brand new accessors regarding a hereditary digital property shall be overridden in good derived class because of the together with property declaration one to specifies an enthusiastic override directive. This can be known as an overriding assets statement. A keen overriding property statement cannot state a unique possessions. Alternatively, it simply focuses the fresh new implementations of your accessors of a preexisting digital property.

Comments are closed.