Group models support genetics, a process which a beneficial derived class can increase and you may specialize a great feet classification

Group models support genetics, a process which a beneficial derived class can increase and you may specialize a great feet classification

A class are a document design that consist of analysis players (constants and you may industries), function users (tips, functions, incidents, indexers, workers, like constructors, finalizers, and static constructors), and you can nested items.

fourteen.dos.step 1 Standard

A category_statement consists of a recommended group of qualities (§21), accompanied by an optional number of class_modifiers (§14.dos.2), followed by an elective partial modifier (§14.2.7), with this new keyword category and you will a keen identifier that labels the brand new group, followed by a recommended sorts of_parameter_list (§14.dos.3), with an elective group_legs specification (§14.dos.4), followed closely by a recommended set of variety of_parameter_constraints_conditions (§14.dos.5), followed by a course_human anatomy (§fourteen.dos.6), optionally followed closely by a beneficial semicolon.

A course eter_list was a simple category statement. Likewise, one category nested in to the a general category declaration or a generic struct declaration try alone a general classification statement, while the form of objections towards the with particular is provided to would a built particular.

14.dos.2.step one Standard

The new modifier is permitted on the nested classes. They determine that group hides a hereditary user by same name, once the described into the §fourteen.3.5. It’s a secure-time error to the the newest modifier to seem on a category report that’s not a nested classification declaration.

People , protected , internal , and personal modifiers control the latest entry to of category. With respect to the perspective where in actuality the class declaration occurs, some of these modifiers may not be permitted (§seven.5.2).

Whenever a partial form of declaration (§14.dos.7) has an access requirements (via the social , safe , inner , and personal modifiers), you to specification should go along with various other bits that come with a keen entry to specs. In the event the no part of a limited sorts of comes with an accessibility specs, the sort is offered the proper standard access to (§eight.5.2).

fourteen.dos.dos.dos Conceptual kinds

The brand new abstract modifier can be used to point you to definitely a category was partial and that it is intended to be used merely once the a base category. A conceptual group differs from a low-conceptual classification regarding the adopting the means:

  • An abstract category cannot be instantiated directly, and is an assemble-big date mistake to use new driver towards the a conceptual classification. Even though it is you can for variables and you will opinions whose secure-date designs was abstract, like variables and you will thinking tend to fundamentally be either null otherwise have references to help you instances of low-conceptual categories based on the new abstract models.
  • An abstract category is permitted (however expected) so you can consist of abstract users.
  • An abstract category can’t be sealed.

When a non-abstract class hails from a conceptual classification, the latest non-abstract class will include genuine implementations of the many passed on conceptual members, thereby overriding the individuals conceptual users.

the newest abstract group A good brings up a conceptual approach F . Classification B raises an extra method G , but since it cannot bring an implementation of F , B will be also announced abstract. Category C overrides F and provides an actual implementation. Because there are no conceptual users during the C , C is let (although not required) to-be non-conceptual. prevent example

If an individual or even more areas of a limited form of statement (§fourteen.2.7) away from a course include the conceptual modifier, the category is actually abstract. If you don’t, the class is actually low-conceptual.

fourteen.2.dos.3 Sealed kinds

The latest shut modifier is employed to end derivation of a class. An amass-big date error happens when the a closed classification was given since legs family of several other group.

Note: This new closed modifier is mainly used to prevent unintended derivation, but it also allows specific run-day optimizations. Specifically, as a sealed class is recognized to haven’t one derived classes, you are able to changes virtual setting user invocations on closed group circumstances on low-virtual invocations. prevent notice

This entry was posted in Uncategorized and tagged . Bookmark the permalink.