|
12 | 12 | \begin{itemize}
|
13 | 13 | \item
|
14 | 14 | \indextext{access control!\idxcode{private}}%
|
15 |
| -\tcode{private}; |
| 15 | +private; |
16 | 16 | that is, its name can be used only by members and friends
|
17 | 17 | of the class in which it is declared.
|
18 | 18 | \item
|
19 | 19 | \indextext{access control!\idxcode{protected}}%
|
20 |
| -\tcode{protected}; |
| 20 | +protected; |
21 | 21 | that is, its name can be used only by members and friends
|
22 | 22 | of the class in which it is declared, by classes derived from that class, and by their
|
23 | 23 | friends (see~\ref{class.protected}).
|
24 | 24 | \item
|
25 | 25 | \indextext{access control!\idxcode{public}}%
|
26 |
| -\tcode{public}; |
| 26 | +public; |
27 | 27 | that is, its name can be used anywhere without access restriction.
|
28 | 28 | \end{itemize}
|
29 | 29 |
|
|
44 | 44 | \tcode{private}
|
45 | 45 | by default.
|
46 | 46 | Members of a class defined with the keywords
|
47 |
| -\tcode{struct} |
48 |
| -or |
49 |
| -\tcode{union} |
50 |
| -are |
51 |
| -\tcode{public} |
52 |
| -by default. |
| 47 | +\tcode{struct} or \tcode{union} |
| 48 | +are public by default. |
53 | 49 | \begin{example}
|
54 | 50 |
|
55 | 51 | \begin{codeblock}
|
|
68 | 64 | referred to from declarations or expressions.
|
69 | 65 | \begin{note}
|
70 | 66 | Access control applies to names nominated by
|
71 |
| -\tcode{friend} |
72 |
| -declarations~(\ref{class.friend}) and |
| 67 | +friend declarations~(\ref{class.friend}) and |
73 | 68 | \grammarterm{using-declaration}{s}~(\ref{namespace.udecl}).
|
74 | 69 | \end{note}
|
75 | 70 | In the case of overloaded function names, access control is applied to
|
|
289 | 284 | If a class is declared to be a base class (Clause~\ref{class.derived}) for another class using the
|
290 | 285 | \tcode{public}
|
291 | 286 | access specifier, the
|
292 |
| -\tcode{public} |
293 |
| -members of the base class are accessible as |
294 |
| -\tcode{public} |
295 |
| -members of the derived class and |
296 |
| -\tcode{protected} |
297 |
| -members of the base class are accessible as |
298 |
| -\tcode{protected} |
299 |
| -members of the derived class. |
| 287 | +public members of the base class are accessible as |
| 288 | +public members of the derived class and |
| 289 | +protected members of the base class are accessible as |
| 290 | +protected members of the derived class. |
300 | 291 | If a class is declared to be a base class for another class using the
|
301 | 292 | \tcode{protected}
|
302 | 293 | access specifier, the
|
303 |
| -\tcode{public} |
304 |
| -and |
305 |
| -\tcode{protected} |
306 |
| -members of the base class are accessible as |
307 |
| -\tcode{protected} |
308 |
| -members of the derived class. |
| 294 | +public and protected members of the base class are accessible as |
| 295 | +protected members of the derived class. |
309 | 296 | If a class is declared to be a base class for another class using the
|
310 | 297 | \tcode{private}
|
311 | 298 | access specifier, the
|
312 |
| -\tcode{public} |
313 |
| -and |
314 |
| -\tcode{protected} |
| 299 | +public and protected |
315 | 300 | members of the base class are accessible as
|
316 |
| -\tcode{private} |
317 |
| -members of the derived class\footnote{As specified previously in Clause~\ref{class.access}, |
| 301 | +private members of the derived class\footnote{As specified previously in Clause~\ref{class.access}, |
318 | 302 | private members of a base class remain inaccessible even to derived classes
|
319 |
| -unless |
320 |
| -\tcode{friend} |
| 303 | +unless friend |
321 | 304 | declarations within the base class definition are used to grant access explicitly.}.
|
322 | 305 |
|
323 | 306 | \pnum
|
|
673 | 656 | \end{example}
|
674 | 657 |
|
675 | 658 | \pnum
|
676 |
| -A \tcode{friend} declaration that does not declare a function |
| 659 | +A friend declaration that does not declare a function |
677 | 660 | shall have one of the following forms:
|
678 | 661 |
|
679 | 662 | \begin{ncsimplebnf}
|
|
682 | 665 | \terminal{friend} typename-specifier \terminal{;}
|
683 | 666 | \end{ncsimplebnf}
|
684 | 667 |
|
685 |
| -\begin{note} A \tcode{friend} declaration may be the |
| 668 | +\begin{note} A friend declaration may be the |
686 | 669 | \term{declaration} in a \grammarterm{template-declaration}
|
687 | 670 | (Clause~\ref{temp}, \ref{temp.friend}).\end{note} If the
|
688 |
| -type specifier in a \tcode{friend} declaration designates a (possibly |
| 671 | +type specifier in a friend declaration designates a (possibly |
689 | 672 | cv-qualified) class type, that class is declared as a friend; otherwise, the
|
690 |
| -\tcode{friend} declaration is ignored. \begin{example} |
| 673 | +friend declaration is ignored. \begin{example} |
691 | 674 |
|
692 | 675 | \begin{codeblock}
|
693 | 676 | class C;
|
|
720 | 703 |
|
721 | 704 | \pnum
|
722 | 705 | \indextext{declaration!overloaded name and \tcode{friend}}%
|
723 |
| -When a |
724 |
| -\tcode{friend} |
| 706 | +When a friend |
725 | 707 | declaration refers to an overloaded name or operator, only the function specified
|
726 | 708 | by the parameter types becomes a friend.
|
727 | 709 | A member function of a class
|
|
758 | 740 |
|
759 | 741 | \pnum
|
760 | 742 | Such a function is implicitly an inline function~(\ref{dcl.inline}).
|
761 |
| -A |
762 |
| -\tcode{friend} |
| 743 | +A friend |
763 | 744 | function defined in a class is in the (lexical) scope of the class in which it is defined.
|
764 | 745 | A friend function defined outside the class is not~(\ref{basic.lookup.unqual}).
|
765 | 746 |
|
|
776 | 757 | class containing the friend declaration.
|
777 | 758 | The meaning of the friend declaration is the same whether the friend declaration
|
778 | 759 | appears in the
|
779 |
| -\tcode{private}, |
780 |
| -\tcode{protected} |
781 |
| -or |
782 |
| -\tcode{public}~(\ref{class.mem}) |
| 760 | +private, protected, or public~(\ref{class.mem}) |
783 | 761 | portion of the class
|
784 | 762 | \grammarterm{member-specification}.
|
785 | 763 |
|
|
0 commit comments