Yes, you can use both C++ and the placement operator new in Palm programming.

But something just occured to me since my last response: Don't put an object in
a handle unless you really, really know what you are doing. You must make sure
that the object can stand moving around in memory.  If there are any internal
pointers to data members, those pointers won't get updated and will be
invalidated the next time the heap is compressed, shufffled, or re-arranged.
Obvious examples are where you have one data member that points to another. A
not-so-obvious example would be when you use multiple-inheritance with virtual
base classes.

-- Keith Rollin
-- Palm OS Emulator engineer






"Miller, Gary" <[EMAIL PROTECTED]> on 12/09/99 01:26:32 PM

Please respond to [EMAIL PROTECTED]

Sent by:  "Miller, Gary" <[EMAIL PROTECTED]>


To:   "'palm-dev-forum @3com.com'" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/HQ/3Com)
Subject:  RE: ::new(p) Foo;




wow.  haven't seen OOP since i started Palm programming.  is that supported?

> -----Original Message-----
> From: Maarten L. Hekkelman [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 09, 1999 04:11 PM
> To: [EMAIL PROTECTED]
> Subject: ::new(p) Foo;
>
>
> Can anyone explain to me why this code generates a Privilage
> violation when
> executing the new operator?
>
> #include <Pilot.h>
> #include <new>
>
> void Foo ();
>
> class Bar
> {
> public:
>     Bar () : mValue (0) {}
>
> private:
>     long mValue;
> };
>
> void Foo ()
> {
>     Bar **b = (Bar**)::MemHandleNew(sizeof(Bar));
>     ::MemHandleLock((VoidHand)b);
>     ::new(*b) Bar;
>     ::MemHandleUnlock((VoidHand)b);
> }
>
> I really thought this was valid code...
>
> -maarten
>
> --
> Maarten L. Hekkelman                      http://www.hekkelman.com
> Hekkelman Programmatuur bv         mailto:maarten at hekkelman.com
>
>
>





Reply via email to