[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] [C++] new class, fail. Ønskes: NULL pointer



On Tue, Jan 13, 2004 at 12:48:12PM +0100, Hans Schou wrote:
> 
> Hej
> 
> Æv, så fik jeg en segmentation fault.
> 
> Jeg opretter et object (class). Under init finder jeg ud af at den går 
> ikke, og så vil jeg gerne have returneret NULL.
> 
> 	foo = new bar();
> 
> I ovenstående skal foo så være NULL, hvis bar() fejler.
> 
> Kan man det? Eller griber jeg det forkert an?
> 
> I virkeligheden er det en hægtet liste,
> så det er nemt at håndtere senere.
> 	link.additem(new bar());

Argh - memleak problemet i mit eksempel før findes slet ikke   :)

Spørgsmål: hvorfor har du en link.additem() ?  Hvorfor ikke bruge en STL
liste?

Spørgsmål 2: hvorfor lave en liste af pointere til objekter istedet for
blot en liste af objekter ?


Hvis du kort kan forklare hvad det er du skal, lover jeg at komme med et
pænt og simpelt eksempel som ikke lækker  ;)

 / jakob



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *