在头文件 xx.h 中定义的函数 Func 如下

namespace AAA
{
  void Func();
}

在cpp文件中实现

#include "xx.h"

namespace AAA
{
  void Func() {}
}

 

此时在其他文件中,在没有include "xx.h" 的情况下,使用函数Func()得先 extern,如

extern void AAA::Func();

Func();

出错!!!提示:"Func" 不是 "AAA"的成员

需如下才正确:

namespace AAA
{
    extern void Func();
}

AAA::Func();

 

posted on 2012-12-12 21:20  布丁嫩  阅读(374)  评论(0)    收藏  举报