Thread View: comp.std.c++
2 messages
2 total messages
Started by Ralph Gonzalez
Mon, 17 Sep 1990 15:06
Constructors/Destructors returning value?
Author: Ralph Gonzalez
Date: Mon, 17 Sep 1990 15:06
Date: Mon, 17 Sep 1990 15:06
19 lines
1138 bytes
1138 bytes
Hi. I'm not much of an expert on C++ (I mostly use Think C 4.0, a similar but less detailed language), so perhaps the following suggestion doesn't make sense stylistically, but here goes: Often I want to dynamically allocate space in my constructor. If there's not enough memory to do so, it would be nice if the 'new' operator simply deleted the object for me and returned NULL. Anything I was able to allocate in the constructor should in this case be deallocated by the constructor before it ends. An alternative would be for 'new' to call the destructor before deleting the un-initializable object. This implies the constructor should return a boolean value, which is made use of by 'new'. What do you think? -Ralph
Re: Constructors/Destructors returning value?
Author: Ron Guilmette
Date: Fri, 21 Sep 1990 04:12
Date: Fri, 21 Sep 1990 04:12
25 lines
1353 bytes
1353 bytes
In article <Sep.17.11.06.04.1990.7553@elbereth.rutgers.edu> rgonzal@elbereth.rutgers.edu (Ralph Gonzalez) writes: < <Often I want to dynamically allocate space in my constructor. If <there's not enough memory to do so, it would be nice if the 'new' <operator simply deleted the object for me and returned NULL. Anything <I was able to allocate in the constructor should in this case be <deallocated by the constructor before it ends. An alternative would <be for 'new' to call the destructor before deleting the <un-initializable object. < <This implies the constructor should return a boolean value, which is <made use of by 'new'. < <What do you think? I think this looks like a job for... ta ta da... exceptions! (applause) :-) :-) -- // Ron Guilmette - C++ Entomologist // Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads