tmp/tmpvo54we89/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Non-static member functions <a id="class.mfct.non.static">[[class.mfct.non.static]]</a>
|
| 2 |
+
|
| 3 |
+
A non-static member function may be called for an object of its class
|
| 4 |
+
type, or for an object of a class derived [[class.derived]] from its
|
| 5 |
+
class type, using the class member access syntax
|
| 6 |
+
[[expr.ref]], [[over.match.call]]. A non-static member function may also
|
| 7 |
+
be called directly using the function call syntax
|
| 8 |
+
[[expr.call]], [[over.match.call]] from within its class or a class
|
| 9 |
+
derived from its class, or a member thereof, as described below.
|
| 10 |
+
|
| 11 |
+
When an *id-expression* [[expr.prim.id]] that is neither part of a class
|
| 12 |
+
member access syntax [[expr.ref]] nor the unparenthesized operand of the
|
| 13 |
+
unary `&` operator [[expr.unary.op]] is used where the current class is
|
| 14 |
+
`X` [[expr.prim.this]], if name lookup [[basic.lookup]] resolves the
|
| 15 |
+
name in the *id-expression* to a non-static non-type member of some
|
| 16 |
+
class `C`, and if either the *id-expression* is potentially evaluated or
|
| 17 |
+
`C` is `X` or a base class of `X`, the *id-expression* is transformed
|
| 18 |
+
into a class member access expression [[expr.ref]] using `(*this)` as
|
| 19 |
+
the *postfix-expression* to the left of the `.` operator.
|
| 20 |
+
|
| 21 |
+
[*Note 1*: If `C` is not `X` or a base class of `X`, the class member
|
| 22 |
+
access expression is ill-formed. — *end note*]
|
| 23 |
+
|
| 24 |
+
This transformation does not apply in the template definition context
|
| 25 |
+
[[temp.dep.type]].
|
| 26 |
+
|
| 27 |
+
[*Example 1*:
|
| 28 |
+
|
| 29 |
+
``` cpp
|
| 30 |
+
struct tnode {
|
| 31 |
+
char tword[20];
|
| 32 |
+
int count;
|
| 33 |
+
tnode* left;
|
| 34 |
+
tnode* right;
|
| 35 |
+
void set(const char*, tnode* l, tnode* r);
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
void tnode::set(const char* w, tnode* l, tnode* r) {
|
| 39 |
+
count = strlen(w)+1;
|
| 40 |
+
if (sizeof(tword)<=count)
|
| 41 |
+
perror("tnode string too long");
|
| 42 |
+
strcpy(tword,w);
|
| 43 |
+
left = l;
|
| 44 |
+
right = r;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
void f(tnode n1, tnode n2) {
|
| 48 |
+
n1.set("abc",&n2,0);
|
| 49 |
+
n2.set("def",0,0);
|
| 50 |
+
}
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
In the body of the member function `tnode::set`, the member names
|
| 54 |
+
`tword`, `count`, `left`, and `right` refer to members of the object for
|
| 55 |
+
which the function is called. Thus, in the call `n1.set("abc",&n2,0)`,
|
| 56 |
+
`tword` refers to `n1.tword`, and in the call `n2.set("def",0,0)`, it
|
| 57 |
+
refers to `n2.tword`. The functions `strlen`, `perror`, and `strcpy` are
|
| 58 |
+
not members of the class `tnode` and should be declared elsewhere.[^2]
|
| 59 |
+
|
| 60 |
+
— *end example*]
|
| 61 |
+
|
| 62 |
+
[*Note 2*: An implicit object member function can be declared with
|
| 63 |
+
*cv-qualifier*s, which affect the type of the `this` pointer
|
| 64 |
+
[[expr.prim.this]], and/or a *ref-qualifier* [[dcl.fct]]; both affect
|
| 65 |
+
overload resolution [[over.match.funcs]] — *end note*]
|
| 66 |
+
|
| 67 |
+
An implicit object member function may be declared virtual
|
| 68 |
+
[[class.virtual]] or pure virtual [[class.abstract]].
|
| 69 |
+
|