I have three source files.
main.cpp
#include "myfunction.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
cin>>n;
cout<<biggestdigit(n);
}
myfunction.h
#ifndef _MYFUNCTION_H_
#define _MYFUNCTION_H_
int biggestdigit(int n);
#endif
myfunction.cpp
#include "myfunction.h"
int biggestdigit(int n){
int m=0;
int ld;
while(n!=0){
ld=n%10;
if(ld>m) m=ld;
n/=10;
}
return m;
}
When I compile main.cpp I get this error:
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASUS\AppData\Local\Temp\ccLhHBXi.o:main.cpp:(.text+0x29): undefined reference to `biggestdigit(int)'
collect2.exe: error: ld returned 1 exit status
What should I do? The only file I'm allowed to include is the header file. The IDE is Visual Studio Code.