So what i want to achieve is global variable which represents pointer to dynamic array of structs which has other pointers to dynamic arrays inside.
So i've declared everything in the header file like that:
/*** "GLOB.h" ***/
//Dynamic Array of fixed Arrays of 4 floats each
typedef float DArray1[][4];
//Dynamic Array of Integers
typedef int DArray2[];
//Struct
struct MyStruct
{
//pointer to DArray1
DArray1 * A1;
//pointer to DArray2
DArray2 * A2;
//Length of A1 and A2
int len = 1;
//Some other simple elements of fixed size
};
//Dynamic Array of Structs
typedef MyStruct DAStructs[];
namespace GLOB
{
//pointer to DAStructs
extern DAStructs * SS;
//Few other simple variables initialized in place
};
Because i don't rly sure if i declared everything properly - first question is: how to declare such data-structure in C/C++?
And second(+third) is: how to properly initialize and finalize it with some variable length?
I guess initialization and finalization should be something like that:
#include "GLOB.h"
namespace GLOB
{
void Init_SS(int len) {
SS = new MyStruct*[len];
for(int k=0; k<len; k++){
SS[k].A1 = new float*[1][4];
for(int j=0; j<4; j++) SS[k].A1[0][j] = 0.0;
SS[k].A2 = new int*[1];
SS[k].A2[0] = 0;
}
}
void Fin_SS() {
int len = length(SS);
for(int k=0; k<len; k++){
delete [] SS[k].A1;
delete [] SS[k].A2;
}
delete [] SS;
}
}
But obviously it's just a mess of nonsense and not the appropriate code...
P.S. i'd rather avoid using or any other solutions cuz i want to learn first of all and second i need as much control over how elements will be placed in memory as possible cuz later i'll need to pass pointer to such structure to other functions imported from DLLs...