C: Initializing struct variables after declaration

后端 未结 3 1085
刺人心
刺人心 2020-12-29 23:11

I encountered this recently but could not figure out why the language would allow b = c; below and fail b = {3, 4}. Is there an issue with allowing the latter ?

<         


        
3条回答
  •  [愿得一人]
    2020-12-29 23:40

    Because that's the definition of the language... I don't think there is any particular reason other than "it makes it harder to write the compiler to allow for this".

    You could do b = T{3, 4} if you have a C++ 11 compiler.

提交回复
热议问题