Malloc on a struct containing a std::vector

后端 未结 5 443
甜味超标
甜味超标 2021-01-14 18:30

Here is the situation :

I use a malloc to allocate memory for a struct. The struct contains various items such as pointers, string variables and vectors.

The

5条回答
  •  爱一瞬间的悲伤
    2021-01-14 18:57

    Using object without constructing it must be an undefined behaviour. Anything may happen at any moment. If you do this, you must not rely on any part of your code to run smoothly, because the language doesn't guarantee anything in this case.

提交回复
热议问题