Q:

How to #include "file.cpp"

I must include file in .cpp format.
For test i create some file with sample content
1. file
main.cpp
#include <iostream>
#include "kod.cpp"

int main(int argc, char *argv[])
{
   int x=42;
   std::cout << x <<std::endl;
   std::cout << asd(x) << std::endl;
   return 0;
}

2. file
kod.h
#ifndef KOD_H
#define KOD_H

class kod
{
    public:
        void asd(int);
    protected:
};

#endif

3. file
kod.cpp
#include <iostream>
#include "kod.h"   
int asd(int a){
    return ++a; 
}

I have not idea why it dosen't work. I recieved errors from Dev-C++ 5.11
kod.cpp:(.text+0x0): multiple definition of `asd(int)'
main.cpp:(.text+0x0): first defined here
[Error] ld returned 1 exit status
Makefile.win    recipe for target 'Projekt5.exe' failed

How I can repair this app. I must use #define "kod.cpp" in main.cpp
Thank's for all advices
Regards

A:

Replace #include "kod.cpp" with #include "kod.h" and make the function you define in the header a member function (at the moment it is just a free function with no relation to the class) by giving it this signature : 
int kod::asd(int a){

And you have to make the signature in the cpp match the signature in the declaration. At the moment you declare it to be void but then on the definition it returns an int.

