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

Because what you've written doesn't make much sense? You can't pass a type as a function parameter to a user defined function, and if you mean the builtin "new" (no capital) then that uses the normal allocator.


I think he meant that MyType is an enum and New is a user-defined function with a huge switch that does allocate (with placement new?) the correct type based on the value of MyType. Yea works, but introduces runtime overhead and is the gate to maintenance hell.


It is basic OOP in C. Look it up.




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

Search: