Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is 'this' not in scope during named member function overload resolution?

From cppreference:

Call to a named function

<...> If the expression E is a primary expression, the name is looked up following normal rules for function calls (which may involve ADL). The function declarations found by this lookup are (due to the way lookup works) either: <...>

b) all member functions of some class T, in which case, if this is in scope and refers to T, *this is used as the implied object argument. Otherwise (if this is not in scope or does not point to T), a fake object of type T is used as the implied object argument, and if overload resolution subsequently selects a non-static member function, the program is ill-formed.

It seems that the second case is about func(arg) calls inside methods. When could this be not in the scope for such cases?

Or is it talking not only about func(arg)-like stuff in methods?

like image 286
ledonter Avatar asked Jan 29 '26 00:01

ledonter


1 Answers

When could this be not in the scope for such cases?

Static member functions.

like image 200
Barry Avatar answered Jan 30 '26 17:01

Barry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!