I am a total beginner in C++ and I'm trying to learn how to add header files to the main. I have 3 files in the same folder (main.cpp, add.cpp, add.h)
main.cpp:
#include <iostream>
#include "add.h"
int main()
{
std::cout << add(3,4);
return 0;
}
add.cpp:
#include "add.h"
int add(int x, int y)
{
return x + y;
}
add.h:
int add(int x, int y);
Whenever I run this from the atom g++ compiler, I get the following error: in function main':<br/>main.cpp:(.text+0x13): undefined reference toadd(int, int)' collect2: error: ld returned 1 exit status
Can someone tell me what mistake am I making?