Skip to content

Commit a446e94

Browse files
committed
[C.128] reword the note on final classes
the issue was raised that it can be interpreted as a claim that final and override are the same; this attempts to make it harder to misread closes #2235
1 parent e76e1ac commit a446e94

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CppCoreGuidelines.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7432,13 +7432,13 @@ We want to eliminate two particular classes of errors:
74327432
* **implicit virtual**: the programmer intended the function to be implicitly virtual and it is (but readers of the code can't tell); or the programmer intended the function to be implicitly virtual but it isn't (e.g., because of a subtle parameter list mismatch); or the programmer did not intend the function to be virtual but it is (because it happens to have the same signature as a virtual in the base class)
74337433
* **implicit override**: the programmer intended the function to be implicitly an overrider and it is (but readers of the code can't tell); or the programmer intended the function to be implicitly an overrider but it isn't (e.g., because of a subtle parameter list mismatch); or the programmer did not intend the function to be an overrider but it is (because it happens to have the same signature as a virtual in the base class -- note this problem arises whether or not the function is explicitly declared virtual, because the programmer might have intended to create either a new virtual function or a new non-virtual function)
74347434

7435-
Note: On a class defined as `final`, it doesn't matter whether you put `override` or `final` on an individual virtual function.
7435+
Note: On a class defined as `final`, each individual virtual function should use either `override` or `final`; there is no semantic difference in this case.
74367436

74377437
Note: Use `final` on functions sparingly. It does not necessarily lead to optimization, and it precludes further overriding.
74387438

74397439
##### Enforcement
74407440

7441-
* Compare virtual function names in base and derived classes and flag uses of the same name that does not override.
7441+
* Compare virtual function names in base and derived classes and flag uses of the same name that do not override.
74427442
* Flag overrides with neither `override` nor `final`.
74437443
* Flag function declarations that use more than one of `virtual`, `override`, and `final`.
74447444

0 commit comments

Comments
 (0)