3 ms·
Yes, in the particular example presented in the article, the lone `malloc()` will work as expected without the placement new since the class is just being refer
by jay-barronville 3y ago
Yes, in the particular example presented in the article, the lone `malloc()` will work as expected without the placement new since the class is just being referenced as a blob of memory (i.e., it's equivalent to a simple C struct) and the members are being set individually in `make_rational()`. That said, this territory of C and C++ compatibility can become a footgun really quickly with all types of undefined behavior.
- matt3210 3y agoMakes sense! Great work!
- jay-barronville 3y agoJust to be clear, even though I submitted this article, I'm not the author.