gpt4 book ai didi

c++ - 在命名成员函数重载解析期间,什么时候 'this' 不在范围内?

转载 作者:太空狗 更新时间:2023-10-29 20:20:35 26 4
gpt4 key购买 nike

来自 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.

第二种情况似乎是关于方法内部的func(arg) 调用。 this 什么时候可以不在这种情况的范围内?

或者它不仅在谈论 func(arg) 之类的方法?

最佳答案

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

静态成员函数。

关于c++ - 在命名成员函数重载解析期间,什么时候 'this' 不在范围内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50063904/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com