Default constructor in C

后端 未结 13 725
孤街浪徒
孤街浪徒 2020-12-07 21:02

Is there a way to have some kind of default constructor (like a C++ one) for C user types defined with a structure?

I already have a macro which works like a fast in

13条回答
  •  忘掉有多难
    2020-12-07 21:42

    Not really. If I remember correctly, the closest you get to classes are structures. You allocate memory and populate the fields. I don't see how you would make a generic constructor type thing for this. Theoretically, you could write a macro which would do some of this. Not sure if that is really worthwhile though.

提交回复
热议问题