The size of a struct
is determined much earlier in the compilation than the setting of the values inside the struct
.
What's the behavior of sizeof used in member initializer?
문제
What's the behavior of sizeof used in member initializer? I can't find a description about exactly that. In the below code example is it safe? ie, after struct
member will the compiler put right size of A
in b
?
struct A
{
int a = 0;
int b = sizeof(A);
int c = 3;
int d = 4;
char s[256];
A()
{
//printf("b = %d\n", b);
}
};
해결책
제휴하지 않습니다 StackOverflow