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

You can’t return null from a constructor (constructors have no return)



What dumb design.

I thought the constructor returned a pointer to the memory created.

No return? Stupid!


FWIW, constructors do not "create" (I assume you mean allocate) memory. That's the job of operator new. A constructor, given a block of untyped memory, will construct an object in it.


Right.

Been a long time.

I would still expect a constructor to return. How can you tell if it failed?




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: