高分关于命名空间的一个有关问题

高分求助关于命名空间的一个问题
可能是因为上次发帖没有说清楚,所以这次重新发一下:
"main.cpp"
#include "test.h"

using namespace std;
int main()
{
myNameSpcce1::printSpcce1Words();
return 0;
}

"test.h"
#ifndef NAMESPACE
#define NAMECPACE

#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::string;

namespace myNameSpcce1
{

std::string Spcce1Words = "words1";
//int Spcce1Val = 10;
//函数声明
void printSpcce1Words();

}
/*
//函数实现放在头文件中,没有问题
void myNameSpcce1::printSpcce1Words()
{
cout<<Spcce1Words<<endl;
}
*/
#endif

"test.cpp"
#include "test.h"


void myNameSpcce1::printSpcce1Words()
{
cout<<Spcce1Words<<endl;
}

我在头文件中定义了一个命名空间,但是想在对应的源文件中实现其中的函数但是vs2010编译器提示:
test.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > myNameSpcce1::Spcce1Words" (?Spcce1Words@myNameSpcce1@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) 已经在 main.obj 中定义
1>D:\MyPrograms\c++\test5\Debug\test5.exe : fatal error LNK1169: 找到一个或多个多重定义的符号
我看了C++primer,但是对于里面并没有给出令人满意的解答。
另外,C++primer中还提出了命名可以跨多个文件定义,但是我也没有调试成功,希望有人能给出例子。
这次豁出去了,把分提高一些。

------解决方案--------------------
探讨

引用:

错误报的很明白了
"test.h"
std::string Spcce1Words = "words1";
头文件中不能定义变量,用命名空间也一样
首先谢谢你的回答。我有两点不明白:
第一,我在原先的程序中(就是不带源文件,但是打开头文件的注释部分),在头文件中定义了变量,程序可以正常执行,所以可能我没有很好理解的回答。
第二,如果我在对应的源文件中定……

------解决方案--------------------
跨文件定义namespace的例子:
C/C++ code

// test.h
#include <iostream>
#include <string>

namespace myNameSpace1
{
    static std::string SpaceWords2 = "words2";    // 定义静态变量OK

    class A
    {
    private:
        std::string Space1Words;                // 在类中定义变量OK
    public:
        A();
        void printSpace1Words();
        void print();                            // 再增加一个成员函数
    };
};

// test.cpp
#include "test.h"

myNameSpace1::A::A()
{
    myNameSpace1::A::Space1Words = "words1";
}

void myNameSpace1::A::printSpace1Words()
{
    std::cout << myNameSpace1::A::Space1Words << std::endl;
}

// test2.h
#include <iostream>
#include <string>

namespace myNameSpace1   // 再声明另外一个类B
{
    class B
    {
    private:
        std::string Space1Words;
    public:
        B();
        void printSpace1Words();
    };
};

// test2.cpp
#include "test.h"
#include "test2.h"

void myNameSpace1::A::print() // 在test.h声明的A中的函数,在test2.cpp中实现
{
    std::cout << "are you happy today?" << std::endl;
}

myNameSpace1::B::B()
{
    myNameSpace1::B::Space1Words = "B::words1";
}

void myNameSpace1::B::printSpace1Words()
{
    std::cout << myNameSpace1::B::Space1Words << std::endl;
}

// main.cpp
#include "test.h"
#include "test2.h"
using namespace myNameSpace1;

int main(int argc, char** argv)
{
    A a;
    a.printSpace1Words();
    a.print();

    B b;
    b.printSpace1Words();

    std::cout << myNameSpace1::SpaceWords2 << std::endl;

    return 0;
}