NameLookup4

来源:互联网 发布:打马赛克软件 编辑:程序博客网 时间:2024/06/07 00:26
// Example 2: Will this compile? //// In some library header:namespace N { class C {}; }int operator+(int i, N::C) { return i+1; }// solution this problem: let operator in N// A mainline to exercise it:#include <numeric>int main(){N::C a[10];std::accumulate(a, a+10, 0);}// Example 1a: Hiding a name  from a base class//struct B{int f( int );int f( double );int g( int );};struct D : public B{using B::g;private:int g( std::string, bool );};D   d;int i;d.f(i);  // ok, means B::f(int)d.g(i);  // error: g takes 2 argsd.B::g(i);


原创粉丝点击