假设我们有一个 DLL,并且应该有一个全局存储在其中的数组将被导出,问题是我们想通过从文件中读取一些内容来初始化它,所以我个人发现自己没有别的办法,只能放它在一个结构中能够使用构造函数进行初始化:
struct Construction{
public:
Construction(){
//do the initialization thing and read the needed data from the file
}
SomeType sTArray[100];
};
__declspec(dllexport) Construction obj();
现在要在哪里使用它,程序员可以初始化对它的引用,然后使用如下引用:
SomeType (&arrayRef)[100]=obj.sTArray;
现在你会认为我在任何情况下都错了吗?