[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







Hej Peter

Du har 99.9(+0.1)% ret

Peter Maersk-Moller <sslug@sslug> wrote on 20-01-2004 10:16:42:

> Nils Ljunggren wrote:
> >>           foo = new bar();
> > burde selvfølgelig hede foo= new bar;
> > constructor() er i C++ en funktion der returner en kopi af en default
> > constructor -- dette bør give problemer!
>
> Hvilke problemer er det ?

Der er vis-a-vis operator new normalt ingen problemer

> Kan man ikke have en konstruktor, der tager argumenter ?
>
>      CMyClass *foo = new CMyClass(a,b);
>
> Hvis, ja, er det så ikke det samme som
>
>      CMyClass *foo = new CMyClass();
>
> på nær argumenterne ?

Det bør det være -- men hvad ikke bør fungere er:
CMyClass foo(); // fejl: foo() er en funktion
CMyClass foo; // ok

Hvad der heller ikke bør fungere er
CMyClass foo= CMyClass; // fejl
CMyClass foo= CMyClass(); //ok - men superflous

Hvad der chokerede mig var min kompilers reaktion på indbyggede typer
int* value_ptr= new int(); // *value_ptr != int() -- dette svarer jo til at
jeg havde skrevet: new int
int* value_ptr= new int(int()) // ok: *value_ptr == 0


Med venlig hilsen / Kind regards
Nils Åke Ljunggren
Senior Developer

IntraVision - www.intravision.dk


Office Phone : +45 7023 2340
Office Fax: +45 7023 2349
Mobile : +45 2613 9966

Mail : sslug@sslug
http://www.intravision.dk
OnLine Meeting Center: http://sametime.intravision.biz/stcenter.nsf

>


 
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] *