following compiles fine with g++:
struct acounter {
long static counter;
void static create() { //reset or create the counter
counter=0;
}
void static count() { //the counter changes its internal value.
counter=counter + 1;
}
};
int main(int argc, char *argv[] ){ //compiles and executes!
//do some random stuff...
return 0;
}
The problem is: as soon as I add "acounter::create();" or "acounter::count();" to the main loop, I get an error:
undefined reference to `acounter::counter'
But I defined "counter" and even initialize it. What is the problem?
(P.S. I can only use static functions as I have to deal with callbacks later - the idea is to use the whole struct only on its global scope without creating instances.)