加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 09:20:37 所属栏目:百科 来源:网络整理
导读:从 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
从 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)的东西吗?

解决方法

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

静态成员函数.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读