How to access a static member in a class with all static methods?
I want to have a group of related functions, but there are also some important data members initialized before any of these functions are called. I thought that a class consisting only of static members would be a way for you. I do not like the compiler in VS2008 when I try to access "a".
Of course, I am missing something small, but still very embarrassed.: P (Even without invalid access "a", the constructor is not called when the testMethod () method is called from the main one.
class IPAddressResolver
{
private:
public:
static int a;
IPAddressResolver();
static void TestMethod();
};
IPAddressResolver::IPAddressResolver()
{
IPAddressResolver::a = 0;
cout << "Creating IPAddressResolver" << endl;
}
void IPAddressResolver::TestMethod()
{
cout << "testMethod" << endl;
}
source
share