I am new to c++, and I am trying to link two c++ files together, but received the error error: ld returned 1 exit status when trying to use the run build task on vs code. I am confused because neither of the files are allowing me to build. Here is my code in the files:
int add(int x, int y)
{
return x + y;
}
#include <iostream>
int add(int x, int y); // needed so main.cpp knows that add() is a function defined elsewhere
int main()
{
std::cout << "The sum of 3 and 4 is: " << add(3, 4) << '\n';
return 0;
}
I've tried using cmake however couldn't get the set up to work, I've tried redoing the files from the beginning which gave the same error