我在使用命名空间的时候,重载了MessageBox,却出现了如下问题
TestServer.obj : error LNK2005: "void __cdecl _farfhy::win32::MessageBoxA(char const *)" (?MessageBoxA@win32@_farfhy@@YAXPBD@Z) already defined in StdAfx.objnamespace _farfhy
{
namespace win32
{
void MessageBox(LPCTSTR lpszText)
{
                      ///自定义代码
}
}
}
我在程序中是这样写的:
_farfhy::win32::MessageBox("xixi");
请问高手,错在何方?(高分相送)

解决方案 »

  1.   

    在前面写上 use namespace _farfhy::win32
    看看还会不会出错(申明:我没试)
      

  2.   

    命名空间不太懂,看样子是命名冲突,
    改为mywin32如何。
      

  3.   

    然后再直接用 MessageBox("xixi")
      

  4.   

    应该是在前面加上
    using namespace _farfhy::win32就行了吧
      

  5.   

    我把MessageBox改为AfxMessageBox就有错了
    错误代码如下
    E:\XVZILING的文件夹\VC工程\TestServer\TestServer.cpp(176) : error C2668: 'AfxMessageBox' : ambiguous call to overloaded function
    代码如下:
    using namespace _farfhy::win32;
    AfxMessageBox("xixi");
    我这样做只是因为调试用了很多AfxMessageBox,我想把它重载,不让它显示
    ,可是老有错