Hacker News new | past | comments | ask | show | jobs | submit login

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.



And 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...


Thanks, you spared me the horrors.


The 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 :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: