Hi.
I would like to access private class data out of a static function as follows:
foo1.h:
class foo1Class {
public:
static int getN();
private:
friend int foo1();
static const int n;
};
foo1.cpp:
#include "foo1.h"
const int foo1Class::n = 77;
int foo1Class::getN()
{
return foo1();
}
static int foo1()
{
return foo1Class::n;
}
Then g++ (3.2.3) tells me:
foo1.cpp: In function `int foo1()':
foo1.cpp:11: `int foo1()' was declared `extern' and later `static'
foo1.h:5: previous declaration of `int foo1()'
Which of course is correct.
So I insert a static declaration of foo1 into foo1.h:
foo1.h:
static int foo1();
class foo1Class {
public:
static int getN();
private:
friend int foo1();
static const int n;
};
Now g++ does not complain anymore.
But when I use foo1Class:
foo2.cpp:
#include "foo1.h"
int test()
{
return foo1Class::getN();
}
I get the warning
foo1.h:6: warning: `int foo1()' declared `static' but never defined
Any idea how to avoid these warnings ?
_______________________________________________
Help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus