I'm trying to design a class that needs to dynamically allocate some memory..
I had planned to allocate the memory it needs during construction, but how do I handle failed memory allocations? Should I throw an exception? I read somewhere that exceptions should only be used for "exceptional" cases, and running out of memory doesn't seem like an exceptional case to me..
Should I allocate memory in a separate initialization routine instead and check for failures and then destroy the class instance gracefully?
Or should I use exceptions instead? The class won't have anything useful to do if these memory allocations should fail..
EDIT: The consensus seems to be that running out of memory IS an exceptional case.
Will see how to go about this.. Thanks.. :)