我有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