Article View: borland.public.cppbuilder.upgrade
Article #56Re: BCB6 to BDS2006 problems with operators
From: John Grabner
Date: Thu, 11 Oct 2007 04:44
Date: Thu, 11 Oct 2007 04:44
27 lines
1578 bytes
1578 bytes
Roland wrote:
> In BCB6 I could overload the = operator like:
>
> TMyClass& __fastcall operator=(TMyClass &p);
>
> TMyClass& __fastcall TMyClass::operator=(TMyClass &p)
> {
> for(int i = 0; i < 4; i++) {
> FEnabled[i] = p.Enabled[i];
> FPosition[i] = p.Position[i];
> }
> FMode = p.Mode;
> FDivider = p.Divider;
> return this;
> }
>
> Now in BDS2006 I get an error msg like:
> [C++ Error] xutility(1645): E2285 No match found for
> 'TMyClass::operator =(const TMyClass)'
>
It needs to be const
TMyClass& __fastcall operator=(const TMyClass &p);
should do the trick.
John.
Technical Details
Message-ID:
<470daa79@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<470c83d5$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10529a,d8a389c9012d5c15 X-Google-Attributes: gid10529a,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 11 Oct 2007 17:44:12 +1300 From: John Grabner <grabnerj@ihug.co.nz> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.upgrade Subject: Re: BCB6 to BDS2006 problems with operators References: <470c83d5$1@newsgroups.borland.com> In-Reply-To: <470c83d5$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 203.173.143.93 Message-ID: <470daa79@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1192077945 203.173.143.93 (10 Oct 2007 21:45:45 -0700) Lines: 27 Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail