Article View: borland.public.cppbuilder.migration
Article #174Re: Problem when i return a Class
From: Remy Lebeau (TeamB)
Date: Mon, 17 Jul 2006 03:44
Date: Mon, 17 Jul 2006 03:44
23 lines
1890 bytes
1890 bytes
"Cherubino Ferrario" <cherferr@tin.it> wrote in message news:44ba7c21@newsgroups.borland.com... > When the program go to line return Istance he call the > destructor of class1 and than the operator = of class1. As it should be, because that is what is really happening. You have declared a local instance of class1 inside of CompileClass() that will be destroyed when it goes out of scope. When you call the 'return' statement, the '=' operator is used to assign that local instance to the instance that is used for the return value, before the local instance is then destroyed. > I have acces viotation because Istance is not allocated. Yes, it is. Your AV has to be caused by something else. What does class1 actually look like? My guess is that your class contains data that you are not duplicating inside the '=' operator properly, so the data ends up being deleted/released multiple times incorrectly. Please show a more complete code snippet. Gambit
Technical Details
Message-ID:
<44bb07bb$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44ba7c21@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 110f51,9c1a1c988e79ed1d X-Google-Attributes: gid110f51,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.migration References: <44ba7c21@newsgroups.borland.com> Subject: Re: Problem when i return a Class Date: Sun, 16 Jul 2006 20:44:35 -0700 Lines: 25 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <44bb07bb$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1153107899 68.69.17.41 (16 Jul 2006 20:44:59 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail