【问题标题】:how to refer to the global namespace [duplicate]如何引用全局命名空间[重复]
【发布时间】:2014-09-18 08:51:51
【问题描述】:

在方法isGood 中,我想使用全局命名空间中的函数isGood。如何避免将isGood 解释为相同的方法而不是全局函数?

bool isGood(){ return_if_it_is_good;}

class X{
int a;
bool isGood(){return isGood(a);}
}

【问题讨论】:

  • 添加范围解析运算符::
  • 使用范围运算符:::isGodd(a)

标签: c++


【解决方案1】:

使用:: 操作员调用:

bool isGood(){ return_if_it_is_good;}

class X{
int a;
bool isGood(){return ::isGood(a);}
}

【讨论】:

    猜你喜欢
    • 2010-10-31
    • 2016-07-21
    • 2011-10-19
    • 2010-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多