Hacker Newsnew | past | comments | ask | show | jobs | submitlogin



This is a great example of how many of the things in C that don't compile in C++ are horrible programming practices, and it's really nice that C++ doesn't allow such garbage.


Actually those are very bad examples. In practice, compilers will produce warnings in all of those examples.

Better examples (of actually useful things) would be things like designated initializers, struct literals, declaring array lengths in args using static, etc.


I don't see what is 'horrible programming practice' about

    int *x = malloc(sizeof(int));


because malloc doesn't return an int, it returns a void


malloc returns a void pointer because it implicitly converts to an int pointer, as it should.




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

Search: