hello i have a question about #include
-
these code is :
//In.h
int sum(int a, int b);#include "In.h"
int sum(int a, int b)
{
return (a+b);
}#include "iostream"
#include "In.h"
using namespace std;int main()
{
int a = sum(1, 2);
cout << a << endl;
}when i complier test05.cpp, it will have a question : ~/cpp/test$ g++ -o test05 test05.cpp /tmp/ccW55H4p.o: In function `main': test05.cpp:(.text+0x19): undefined reference to `sum(int, int)' collect2: ld returned 1 exit status give me some advides thank you
-
these code is :
//In.h
int sum(int a, int b);#include "In.h"
int sum(int a, int b)
{
return (a+b);
}#include "iostream"
#include "In.h"
using namespace std;int main()
{
int a = sum(1, 2);
cout << a << endl;
}when i complier test05.cpp, it will have a question : ~/cpp/test$ g++ -o test05 test05.cpp /tmp/ccW55H4p.o: In function `main': test05.cpp:(.text+0x19): undefined reference to `sum(int, int)' collect2: ld returned 1 exit status give me some advides thank you
-
You need to include
In.cpp
in your build thus:~/cpp/test$ g++ -o test05 test05.cpp In.cpp
Just say 'NO' to evaluated arguments for diadic functions! Ash
thank you very much
-
thank you very much