test.h
typedef struct firstStruct
{
int x;
int y;
}firstStruct;
typedef struct secondStruct
{
int a;
char b;
firstStruct c[a];
}secondStruct;
test.cpp
#include "test.h"
#include <stdio.h>
int main(void)
{
firstStruct f;
f.x = 1;
f.y = 2;
secondStruct s;
s.a = 0;
s.b = 'B';
printf("nf.x : %dn", f.x);
printf("nf.y : %dn", f.y);
printf("ns.a : %dn", s.a);
printf("ns.b : %cn", s.b);
return 0;
}
% g++ -o test test.cpp
In file included from test.cpp:1:
test.h:9: error: invalid use of non-static data member `secondStruct::a'
test.h:11: error: from this location
배열의 동적할당을 하려면 어떻게 해야할까요.