This is my code
#include<iostream>
//#include<cmath>
double sqrt(double);
int main()
{
using namespace std;
cout << sqrt(16) << endl;
cin.get();
return 0;
}
I am only exploring into c++ and supposedly[C++ Primer, Lippman] this form of function prototyping should be working.
My code works if I replace double sqrt(double);
with the commented line #include<cmath>
But why does the other method throw this error:
$ g++ so_c++1_FntnPrototype.cpp -lm
/tmp/cc45Ec4F.o: In function `main':
so_c++1_FntnPrototype.cpp:(.text+0x22): undefined reference to `sqrt(double)'
collect2: error: ld returned 1 exit status