Hello, I have the following class with overloaded constructor.
class a { public: a(); a(UInt32); ~a(); };
Now I want to instantiate the class using the a(UInt32) constructor. On a PC I would use: a* obj = new a(1);
I want the object memory to be a movable chunk (MemHandle). How do I pass arguments to the constructor?
C++ objects don't like to live in movable chunks -- the language tends to prefer objects being in chunks of memory that won't move at runtime. However, there are two things you can do:
1) Make your object just a MemHandle and have it do its own allocation/locking/unlocking/freeing of the MemHandle as part of its lifetime, using a private struct to define the memory space of the MemHandle-based data.
2) Allocate an object-sized chunk using MemHandleNew, lock it, use a in-place constructor, and make sure it's locked before any uses. This won't work well for some complex objects that may contain internal pointer to other parts of the object.
-- Ben Combee, Technical Lead, Developer Services, PalmSource, Inc. "Combee on Palm OS" weblog: http://palmos.combee.net/ Developer Fourm Archives: http://news.palmos.com/read/all_forums/
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
