请问如何在一个cpp文件中调用另外一个cpp文件?
两个同在一个project中的cpp文件,定义如下:
#ifndef CPP1_CPP_//cpp1.cpp
#define CPP1_CPP_
#include<iostream>
using namespace std;
extern void test()
{
cout<<"this is the cpp1.print"<<endl;
}
#endif
#include<iostream>//cpp.cpp引用cpp1.cpp中的test函数。
using namespace std;
#include<stdlib.h>
#include<stdio.h>
#include "cpp1.cpp"
//#include"test.h"
void main(void)
{
test();
system("pause");
}
报出连接错误如下:
cpp1.obj : error LNK2005: "void __cdecl test(void)" (?test@@YAXXZ) already defined in cpp.obj
Debug/cpp.exe : fatal error LNK1169: one or more multiply defined symbols found
请教如何解决?