Designated initializer as a private class member?

Hi there,

I want a private class member, which is an array of structs. It would be preferred that I can use an initializer list, but that doesn't seem to work as a private class member.

The following works...

test2.ino:

typedef struct my_data {
    int a;
    const char *name;
    double x;
} my_data;

my_data data[]={
    { 0, "Peter", 0 },
    { 0, "James", 0 },
    { 0, "John", 0 },
    { 0, "Mike", 0 }
};

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("Delay for 5 seconds...");
  
  delay(5000); 
}

However, if I move that code into the header file of a class, I get the error below:

test2.ino:

#include "TestClass.h"

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("Delay for 5 seconds...");
  
  delay(5000); 
}

TestClass.h

#ifndef TestClass_h
#define TestClass_h

#include "Arduino.h"

typedef struct my_data {
    int a;
    const char *name;
    double x;
} my_data;

class TestClass {
    public:
        TestClass(void);
    
    private:
        my_data data[]={
            { 0, "Peter", 0 },
            { 0, "James", 0 },
            { 0, "John", 0 },
            { 0, "Mike", 0 }
        };
};

#endif

The error:

Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
In file included from d:\test2\test2.ino:12:0:

sketch\TestClass.h:40:9: error: too many initializers for 'my_data [0]'

         };

         ^

exit status 1
[Error] Exit with code=1

It does however compile and work if I am explicit on the number of array members.

TestClass.h

#ifndef TestClass_h
#define TestClass_h

#include "Arduino.h"

typedef struct my_data {
    int a;
    const char *name;
    double x;
} my_data;

class TestClass {
    public:
        TestClass(void);
    
    private:
        my_data data[4]={
            { 0, "Peter", 0 },
            { 0, "James", 0 },
            { 0, "John", 0 },
            { 0, "Mike", 0 }
        };
};

#endif

For sure, I can be explicit and move on, but I would like to understand why it doesn't work as a private class member and how it can be made to work?

Any ideas on this one?

C++ does not support variable length array member initialization.