假设我有这门课程:
class __declspec(dllexport) MyClass
{
public:
static int Bar;
static MyOtherClass Foo;
private:
static int OtherStuff;
};
我有一些问题(我使用的是MSVC编译器):
private:
?MyOtherClass
定义类__declspec(dllexport)
,我相信这意味着MSVC编译器会发出警告C4251
,但这是否意味着变量Foo
导入此类的客户端无法访问?我基本上只是在我的脑海中运行各种场景,试图在静态数据成员方面找出DLL类接口中什么是未导出(以及因此无法访问)。
答案 0 :(得分:0)
代码:
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;
我在Dependency Walker中得到以下内容:
class MyClass & MyClass::operator=(class MyClass const &)
int MyClass::Bar
class MyOtherClass MyClass::Foo
int MyClass::OtherStuff
显然已导出变量MyClass::Foo
,但类MyOtherClass
不。如果您尝试从该静态变量访问MyOtherClass::something
,我不确定在这种情况下会发生什么。