#include<stdio.h>
#include<stdlib.h>
class Lib
{
public:
inline static const void Test()
{
printf("this is lib1\n");
};
void Lib1Test()
{
Lib::Test();
}
};
#include<stdio.h>
#include<stdlib.h>
class Lib
{
public:
inline static const int Test()
{
printf("this is lib2\n");
};
void Lib2Test()
{
Lib::Test(); // this will call the Test in Lib1,amazing!
}
};
lib1.a和lib2.a将链接在一起进行测试。
是什么原因? Lib :: Test没有重新定义吗?
答案 0 :(得分:2)
这违反了One Definition Rule,它会使您的程序无效,但不需要实施来诊断它。
答案 1 :(得分:1)