Skip to content

Commit 21d6761

Browse files
authored
Clarify NR.7 ("Don't make data members protected") (#2273)
Made NR.7 ("Don't make all data members `protected`") clearer by removing the word "all". Used the default formulation of C.133 ("Avoid `protected` data") as hyperlink text, linking to C.133. Used the old hyperlink text ("Make member data `public` or (preferably) `private`") as alternative formulation of C.133.
1 parent 177b50e commit 21d6761

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

CppCoreGuidelines.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7773,6 +7773,8 @@ This kind of "vector" isn't meant to be used as a base class at all.
77737773

77747774
### <a name="Rh-protected"></a>C.133: Avoid `protected` data
77757775

7776+
**Alternative formulation**: Make member data `public` or (preferably) `private`.
7777+
77767778
##### Reason
77777779

77787780
`protected` data is a source of complexity and errors.
@@ -20560,7 +20562,7 @@ Non-rule summary:
2056020562
* [NR.4: Don't insist on placing each class definition in its own source file](#Rnr-lots-of-files)
2056120563
* [NR.5: Don't use two-phase initialization](#Rnr-two-phase-init)
2056220564
* [NR.6: Don't place all cleanup actions at the end of a function and `goto exit`](#Rnr-goto-exit)
20563-
* [NR.7: Don't make all data members `protected`](#Rnr-protected-data)
20565+
* [NR.7: Don't make data members `protected`](#Rnr-protected-data)
2056420566
* ???
2056520567

2056620568
### <a name="Rnr-top"></a>NR.1: Don't insist that all declarations should be at the top of a function
@@ -20900,7 +20902,7 @@ and spot the bug.
2090020902
* Use exceptions and [RAII](#Re-raii)
2090120903
* for non-RAII resources, use [`finally`](#Re-finally).
2090220904

20903-
### <a name="Rnr-protected-data"></a>NR.7: Don't make all data members `protected`
20905+
### <a name="Rnr-protected-data"></a>NR.7: Don't make data members `protected`
2090420906

2090520907
##### Reason
2090620908

@@ -20914,7 +20916,7 @@ and spot the bug.
2091420916

2091520917
##### Alternative
2091620918

20917-
* [Make member data `public` or (preferably) `private`](#Rh-protected)
20919+
* [Avoid `protected` data](#Rh-protected)
2091820920

2091920921

2092020922
# <a name="S-references"></a>RF: References

0 commit comments

Comments
 (0)