December 31, 2006
Luís Marques wrote:
> Frits van Bommel wrote:
>> Yes they do take parameters, and the reason is indeed to customize how memory is allocated. But unless they throw an exception, they do have to actually _allocate_ some memory. If they don't throw, the return value must be a void* to a newly-allocated piece of memory.
>> So what I gather you're trying to do (potentially return a pointer to an already-existing object) isn't acceptable behavior for a custom allocator.
> You are right. If I return an existing object it will be initialized to default values. I guess that means the solution to a singleton pattern proposed by Burton Radons does not work ( 
> Still, it's a pity that "new ClassType()" cannot be used to transparently return an existing object (conditionally or not).
> -- 
> Luís Marques

Why should "new ClassType()" be able to return the same instance? What's wrong with ClassType.getInstance() ? Or in your case ClassType.getInstance("my string") ?

Bruno Medeiros - MSc in CS/E student
Next ›   Last »
1 2