C
cppsks
The following seems to work for g++. Is it legal though? I was thinking that
ALL non-const statics have to be initialized in the source files somewhere.
#include <iostream>
namespace nvps
{
static bool hi = false;
class Whatever
{
public:
static void printme();
};
}
void
nvps::Whatever:rintme()
{
cout << hi << endl;
hi = true;
cout << hi << endl;
}
int main()
{
nvps::Whatever:rintme();
}
~/personal/C++/>a.out
0
1
ALL non-const statics have to be initialized in the source files somewhere.
#include <iostream>
namespace nvps
{
static bool hi = false;
class Whatever
{
public:
static void printme();
};
}
void
nvps::Whatever:rintme()
{
cout << hi << endl;
hi = true;
cout << hi << endl;
}
int main()
{
nvps::Whatever:rintme();
}
~/personal/C++/>a.out
0
1