在一些存储过程中,如果发现变量很多, 或者需要读取配置文件并保存配置文件中的内容就可以用如下的一些存储过程, 主要是用多个结构体的套用,加上静态成员变员进行。
.h 文件的声明如下:
struct A {
static const QString H;
struct B {
QString E;
struct C {
QString F;
} testC;
struct D {
QString G;
} testD;
} testB;
} testA;
那么.cpp文件可以这样使用:
const QString testA::H = QLatin1String("J");
testA testStruct;
testStruct.testB.E = QLatin1String("E");
testStruct.testB.testC.F = QLatin1String("F");
也可以:
testStruct.testB.testD.G = testStruct::H;
所以, struct 中多个嵌入和静态变量的同时使用, 是灵活多变的,而且,在存储的过程中起着很重要的作用。