2.3 KiB
[class.mfct]
11 Classes [class]
11.4 Class members [class.mem]
11.4.2 Member functions [class.mfct]
If a member function is attached to the global module and is defined ([dcl.fct.def]) in its class definition, it is inline ([dcl.inline]).
[Note 1:
A member function is also inline if it is declaredinline, constexpr, or consteval.
â end note]
[Example 1: struct X {typedef int T; static T count; void f(T);};void X::f(T t = count) { }
The definition of the member function f of class X inhabits the global scope; the notation X::f indicates that the function f is a member of class X and in the scope of class X.
In the function definition, the parameter type T refers to the typedef member T declared in class X and the default argument count refers to the static data member count declared in class X.
â end example]
Member functions of a local class shall be defined inline in their class definition, if they are defined at all.
[Note 2:
A member function can be declared (but not defined) using a typedef for a function type.
The resulting member function has exactly the same type as it would have if the function declarator were provided explicitly, see [dcl.fct] and [temp.arg].
[Example 2: typedef void fv();typedef void fvc() const;struct S { fv memfunc1; // equivalent to: void memfunc1();void memfunc2(); fvc memfunc3; // equivalent to: void memfunc3() const;}; fv S::* pmfv1 = &S::memfunc1; fv S::* pmfv2 = &S::memfunc2; fvc S::* pmfv3 = &S::memfunc3; â end example]
â end note]