Complete amateur question I'm sure, my apologies, but any help would be greatly appreciated and will likely save my hair line.
I have a header file called "endian.h"
Within this I have:
-------------------
#include <iostream>
struct Endian
{
static bool machine_is_little_endian(); //which returns true iff computer is little endian
...
}
-------------------
I have a file called "endian.c"
--------------------
#include <iostream>
#include <endian.h>
using namespace std;
static bool machine_is_little_endian(){
return 0; //because it's big endian
}
----------------------
and a file called "test.c"
----------------------
#include <iostream>
#include <endian.h>
using namespace std;
int main(){
cout << Endian::machine_is_little_endian() << endl;
return 0;
}
-----------------------
And then I go to compile it (g++) and I get "undefined reference to Endian::machine_is_little_endian()"
...I'm losing my mind...
I can get other member functions in Endian working just fine, I declare an Endian variable "x" and then go "x.printZero()" (assuming that printZero is declared and implemented in endian.h and .c). I can't figure out how to get static functions to work though!
If anyone could help me out...just to get test.c printing the return value from the static function would be super!
Thanks very much
~G