Suppose I have this class:
class __declspec(dllexport) MyClass
{
public:
static int Bar;
static MyOtherClass Foo;
private:
static int OtherStuff;
};
I have some questions (I'm using an MSVC compiler):
private:
?MyOtherClass
is not defined with __declspec(dllexport)
, I believe this means warning C4251
will be issued by the MSVC compiler, but does this mean that variable Foo
will not be accessible to clients that import this class?I'm basically just running various scenarios through my mind, trying to figure out what is and what isn't exported (and thus inaccessible) in a DLL class interface in terms of static data members only.
For the code:
class MyOtherClass
{
public:
int something;
};
class __declspec(dllexport) MyClass
{
public:
static int Bar;
static MyOtherClass Foo;
private:
static int OtherStuff;
};
int MyClass::Bar = 0;
MyOtherClass MyClass::Foo;
int MyClass::OtherStuff = 0;
I get the following in Dependency Walker:
class MyClass & MyClass::operator=(class MyClass const &)
int MyClass::Bar
class MyOtherClass MyClass::Foo
int MyClass::OtherStuff
Apparently variable MyClass::Foo
is indeed exported, but class MyOtherClass
is not. I'm not sure what happens in this case if you try to access MyOtherClass::something
from that static variable.