As @crashmstr mentioned, you are not initializing a member of the structure, but a local variable. The following code should work:
struct Struct1 { float array1[2]; //ctor Struct1(); }; Struct1::Struct1() : array1 ({0.2,1.3}) { } int main() { Struct1 StructEx; std::cout<<StructEx.array1[0]<<' '; std::cout<<StructEx.array1[1]<<std::endl; return 0; }
source share