C++ 两个文件中的同名类

test1.cpp

#include<iostream>
using namespace std;

void test();
class Person
{
public:
    void func()
    {
        cout << "测试1!" << endl;
    }
};

int main()
{
    Person p1;
    p1.func();
    test();
    system("pause");
    return 0;
}

test2.cpp

#include<iostream>
using namespace std;

class Person
{
public:
    void func()
    {
        cout << "测试2!" << endl;
    }
};

void test()
{
    Person p1;
    p1.func();
}

为什么最后的输出结果是:
测试1!
测试1!

test2.cpp根本没有被链接,否则会报Person 重定义的链接错误,根本不能生成exe