Have error code LNK2005 and LNK 1169 in Visual Studio 2019

  c++, visual-c++, visual-studio

First I wrote this in main.cpp

#include <iostream>
#include "functions.cpp"

int main()
{
    int n = 5;
    std::cout << cube(n) << std::endl;
    return 0;
}

Then I wrote this in functions.cpp

int cube(int n)
{
    return n * n * n;
}

I am always receiving errors LNK2005 and LNK 1169, I have read something about use of extern keyword but don’t really know how to implement it in my case.
Thanks in advance

Source: Windows Questions C++

LEAVE A COMMENT