Using more than one file

I am thinking of using more than 1 file for a project.
I wrote a program for test purposes..Some appears to be wrong,have I missed something very basic?

main.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include "test.cpp"
#include "test.hpp"

using namespace std;


int main()
{
    
    cout<<test_func();
    return 0;
}


test.cpp
1
2
3
4
int test_func()
{
    return 0;
}




test.hpp
int test_func();



the error m. is as follows:
obj\Debug\main.o||In function `Z9test_funcv':|
d:\c++_pj_exps\test\test.cpp|3|multiple definition of `test_func()'|
obj\Debug\test.o:d:\c++_pj_exps\test\test.cpp|3|first defined here|
||=== Build finished: 2 errors, 0 warnings ===|
Don't include .cpp files. That's what header files are for.
Thanks....will be testing classes now..
Topic archived. No new replies allowed.