Click here to Skip to main content
15,886,199 members

Comments by Cedric Moonen (Top 31 by date)

Cedric Moonen 20-Jun-11 4:26am View    
Yes, so ? What is the problem with the solutions I provided you ? Did you even read my answer ?
Cedric Moonen 20-Jun-11 4:15am View    
Your buffer is NULL, so how can you add bytes to a non-existent buffer ? You will first need to allocate a buffer for 40 bytes (using new in C++ or malloc in C). Of course, you won't be able to add bytes to that buffer after that except if you use one of the solutions I provided.
Cedric Moonen 20-Jun-11 2:22am View    
Could you also post the exact error message displayed when your code crashes ?
Cedric Moonen 17-Jun-11 3:26am View    
In fact this "trick" comes handy in some specific situations: for a specific factory design pattern. If you make the factory a singleton, then each element that has to be created by the factory can register itself (before the main starts) using this technique. This allows to decouple the factory from the elements it has to create.
Cedric Moonen 17-Jun-11 2:48am View    
Look at the solution I provided (solution 7), this is doing something similar as your java code...