🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #1434

Re: CWP6: illegal implicit conversion...

#1434
From: Ronald Webster
Date: Thu, 21 Sep 2000 00:00
56 lines
2357 bytes
Looks to me like OnDraw wants a reference to an object, which is a veiled
way of sending the address of the object, rather than the value of the
object, to the function.
In order to have this, you must have the object itself, i.e. an instance of
the class CP_Region.
In your second example, you have an instance: cpr.
In your first example, you don't. All you have is the value.

Try this:

int Myfuncref(int& x)
{
    return(x);
}

int Myfuncval(int x)
{
    return(x);
}

Then in main()...

q=Myfuncref(2);    // This line generates an error.
q=Myfuncval(2);

You'll get a compiler error. The reason is that you can't take the address
of 2. Same problem you're having. If you want to call by reference, you
have to have an object, not just the value it leaves behind.

Good luck.

-Ron Webster

Gordon Tillman wrote:

> Howdy All,
>
> I was recompiling my CPLAT sources (from Ken Stahlman) under CWP6 and
> encountered several places in the code where I am now receiving this
> error. (Don't worry about what a CP_Region is...suffice it to say its a
> valid thing)s:
>
>     Error: illegal implicit conversion from 'CP_Region' to 'CP_Region &'
>
> Here is the snippet of code that causes the error:
>
>     OnDraw( CP_Region(fPlatformWindow->visRgn) );
>
> Now, if I change the code to read like this:
>
>     CP_Region cpr(fPlatformWindow->visRgn);
>     OnDraw( cpr);
>
> Then it compiles fine.  I wonder why this is so???
>
> --gordon
Technical Details
Message-ID: <39CA675B.AFC6599C@optonline.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <39CA60B0.DC1700A2@mindspring.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10bcce,4a0d644260b480cb
X-Google-Attributes: gid10bcce,public
X-Google-Thread: f635e,4a0d644260b480cb
X-Google-Attributes: gidf635e,public
From: Ronald Webster <ronw@optonline.net>
Subject: Re: CWP6: illegal implicit conversion...
Date: 2000/09/21
Message-ID: <39CA675B.AFC6599C@optonline.net>
X-Deja-AN: 672580206
Content-Transfer-Encoding: 7bit
References: <39CA60B0.DC1700A2@mindspring.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353"
X-Trace: news02.optonline.net 969566039 24.188.43.238 (Thu, 21 Sep 2000 15:53:59 EDT)
Organization: Optimum Online
MIME-Version: 1.0
Reply-To: ronw@optonline.net
NNTP-Posting-Date: Thu, 21 Sep 2000 15:53:59 EDT
Newsgroups: comp.sys.mac.programmer.codewarrior,codewarrior.mac