Hi, new to this so go easy.
I'm trying to store a function i wrote in a file and call it with a header file rather than copy and paste as ive been doing but i keep getting error messages from the compiler.
Can anyone point out what i'm doing wrong?
the header file is:
#ifndef GUARD_is_prime_h
#define GUARD_is_prime_h
bool is_prime(unsigned long long int);
#endif
this is saved as is_prime.h
is_prime.cpp is;
bool is_prime(unsigned long long int a)
{
if(a==1){return false;}
if(a<4){return true;}
if(a%2==0){return false;}
if(a<9){return true;}
if(a%3==0){return false;}
unsigned long long int i;
for(i=5;(i*i)<=a;i+=6)
{
if(a%i==0){return false;}
if(a%(i+2)==0){return false;}
}
return true;
}
i then tried to write a simple program that asks if a number is prime having used
#include "is_prime.h" and i get the following error
In function main
[Linker error]undefined reference to is_prime(unsigned long long)
Id returned 1 exit status
any help greatly appreciated.:)