c – 在命名成员函数重载决策期间,’this’何时不在范围内?

c – 在命名成员函数重载决策期间,’this’何时不在范围内?,第1张

概述从 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 declar 从 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)调用.什么时候不适合这种情况?

或者它不只是在谈论方法中的类似func(arg)的东西吗?

解决方法@H_404_26@

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

静态成员函数.

总结

以上是内存溢出为你收集整理的c – 在命名成员函数重载决策期间,’this’何时不在范围内?全部内容,希望文章能够帮你解决c – 在命名成员函数重载决策期间,’this’何时不在范围内?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1212002.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存