Re: frage zu objecten in c++

Jörg Pauly <[email protected]>
Newsgroups gmane.linux.suse.programming
Message-ID <[email protected]>
Am Mittwoch, 16. November 2005 23:06 schrieb Frank Lanitz:
> 'n Abend!
>
> Am Mittwoch 16 November 2005 22:50 schrieb Johanns Schneider:
> > int main()
> > {
> >     test Test = test();
> >     delete &Test;
>
> Schuss ins Blaue. Sollte vor einem delete nicht ein new stehen oder
> täausche ich mich da?

Genau, Test wird auf dem Stack angelegt.

	test *Test = new test;

So landet's auf dem Heap und kann hinterher mit
	
	delete Test;

gekillt werden.

Auch ruft man niemals explizit den Destruktor auf, das ist "pfui"!

Grüsse aus Meissen
Jörg

-- 
Um die Liste abzubestellen, schicken Sie eine Mail an:
    [email protected]
Um eine Liste aller verfügbaren Kommandos zu bekommen, schicken
Sie eine Mail an: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.