|
894 | 894 | };
|
895 | 895 |
|
896 | 896 | void tnode::set(const char* w, tnode* l, tnode* r) {
|
897 |
| - count = strlen(w)+1; |
898 |
| - if (sizeof(tword)<=count) |
| 897 | + count = strlen(w) + 1; |
| 898 | + if (sizeof(tword) <= count) |
899 | 899 | perror("tnode string too long");
|
900 |
| - strcpy(tword,w); |
| 900 | + strcpy(tword, w); |
901 | 901 | left = l;
|
902 | 902 | right = r;
|
903 | 903 | }
|
904 | 904 |
|
905 | 905 | void f(tnode n1, tnode n2) {
|
906 |
| - n1.set("abc",&n2,0); |
907 |
| - n2.set("def",0,0); |
| 906 | + n1.set("abc", &n2, 0); |
| 907 | + n2.set("def", 0, 0); |
908 | 908 | }
|
909 | 909 | \end{codeblock}
|
910 | 910 |
|
911 | 911 | In the body of the member function \tcode{tnode::set}, the member names
|
912 | 912 | \tcode{tword}, \tcode{count}, \tcode{left}, and \tcode{right} refer to
|
913 | 913 | members of the object for which the function is called. Thus, in the
|
914 |
| -call \tcode{n1.set("abc",\&n2,0)}, \tcode{tword} refers to |
915 |
| -\tcode{n1.tword}, and in the call \tcode{n2.set("def",0,0)}, it refers |
| 914 | +call \tcode{n1.set("abc", \&n2, 0)}, \tcode{tword} refers to |
| 915 | +\tcode{n1.tword}, and in the call \tcode{n2.set("def", 0, 0)}, it refers |
916 | 916 | to \tcode{n2.tword}. The functions \tcode{strlen}, \tcode{perror}, and
|
917 | 917 | \tcode{strcpy} are not members of the class \tcode{tnode} and should be
|
918 | 918 | declared elsewhere.\footnote{See, for example, \tcode{<cstring>}~(\ref{c.strings}).}
|
|
1476 | 1476 | \enterexample
|
1477 | 1477 |
|
1478 | 1478 | \begin{codeblock}
|
1479 |
| -enum BOOL { FALSE=0, TRUE=1 }; |
| 1479 | +enum BOOL { FALSE = 0, TRUE = 1 }; |
1480 | 1480 | struct A {
|
1481 | 1481 | BOOL b:1;
|
1482 | 1482 | };
|
|
0 commit comments