> From: Johnathan Smith
> I am trying to use the SetFieldTextFromStr code but I
> am getting the following error
> Error : illegal implicit conversion from 'void *' to
> 'char *'
> Starter.cpp line 221 StrCopy( MemHandleLock(txtH),
> strP );
I answered this off-line, but for the benefit of any other newbies who are
getting "invalid implicit conversion" errors, here is what I said...
-------------------
C++ is very picky.
Look up the definition of StrCopy and you'll see:
Char *StrCopy (Char *dst, const Char *src)
Now, look up the return value of MemHandleLock and you'll see:
MemPtr MemHandleLock (MemHandle h)
Then you know that MemHandleLock returns a MemPtr (which is actually just
void *) but StrCopy expects a Char * (which happens to be the same as char
*). So that's your problem.
The solution? You have to use type casting all over the place in C++. C
compilers will just do the type conversion for you (void * to char *), but
C++ compilers complain.
So, use
StrCopy( (Char *)MemHandleLock(txtH), strP );
My personal advice: don't use C++ unless you really have to!
-------------------
(Note to group: don't flame me for not liking C++; go right ahead and use it
if you know what you're doing!)
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/