8 ms·
Your allocation method - malloc + cast - may work for simple classes but overall it's a serious no-no; think you should either be using new/delete, or, if stick
by tragomaskhalos 3y ago
Your allocation method - malloc + cast - may work for simple classes but overall it's a serious no-no; think you should either be using new/delete, or, if sticking with malloc /free, use placement new and an explicit destructor call respectively.
- jwatzman 3y agoThe article discusses constructors and how to make them work under "Linking the C++ standard library". I wonder if placement new would run into the same linker problem that the article mentions -- I'll have to try it at some point :)
- krater23 3y agoAnd the stupidest thing, he uses this malloc in a .cc file, where it would no issue to just use new. Thats the point where I stopped reading. After auto main() -> int { ... } I didn't supposed that anything really meaningful can come...
- intelVISA 3y agoThanks, you spared me the horrors.