spetsacdc
March 2nd, 2008, 01:44 AM
Hello, I need to make a global variable for a number. I have a function that calculates this number. This function has its own .h and .cpp files.
In my main program .cpp file I have:
#include "findnumber.h"
double theglobalvar = findnumber();
int main(){ .... etc ....
My problem is I don't know how to use the function to declare my global variable to be the return value of the function.
It doesn't like me calling the findnumber function outside of main. The compiler says:
In function `__static_initialization_and_destruction_0(int, int)':project_4.cpp:(.text+0xd4): undefined reference to `findnumber()'
collect2: ld returned 1 exit status
Any ideas?
Thanks
In my main program .cpp file I have:
#include "findnumber.h"
double theglobalvar = findnumber();
int main(){ .... etc ....
My problem is I don't know how to use the function to declare my global variable to be the return value of the function.
It doesn't like me calling the findnumber function outside of main. The compiler says:
In function `__static_initialization_and_destruction_0(int, int)':project_4.cpp:(.text+0xd4): undefined reference to `findnumber()'
collect2: ld returned 1 exit status
Any ideas?
Thanks