私の関数test
は2つの異なる.cpp
ファイルに追加され、関数は以下に示すようにそれぞれのファイルにプライベートです
test1.cpp
#include <iostream>
using namespace std;
void test()
{
cout << "test" << endl;
}
test2.cpp
#include <iostream>
using namespace std;
void test()
{
cout << "test" << endl;
}
main.cpp
#include <iostream>
using namespace std;
int main()
{
return 0;
}
リンク中にエラーmultiple definition of test()
が発生しますが、2 つのファイルに独自のプライベート スコープがあることを考えると、どのようにそれが可能なのでしょうか!? .cpp
各-files の対応するヘッダーに関数プロトタイプを含めれば理解できましたが、この例ではそのようなことはありません。