我有3个文件Test.h,Test.cpp的和main.cpp中命名空间的错误而宣告它全球范围内
Test.h
#ifndef Test_H
#define Test_H
namespace v
{
int g = 9;;
}
class namespce
{
public:
namespce(void);
public:
~namespce(void);
};
#endif
Test.cpp的
#include "Test.h"
namespce::namespce(void)
{
}
namespce::~namespce(void)
{
}
Main.cpp
#include <iostream>
using namespace std;
#include "Test.h"
//#include "namespce.h"
int main()
{
return 0;
}
构建它提供了以下错误时..
1>namespce.obj : error LNK2005: "int v::g" ([email protected]@@3HA) already defined in main.obj
1>C:\Users\E543925\Documents\Visual Studio 2005\Projects\viku\Debug\viku.exe : fatal error LNK1169: one or more multiply defined symbols found
敬请尽快帮助..
谢谢.. 得到了解决方案.. – Kenta 2012-07-27 11:15:52