Thanks a lot John , Dave and Ben. All this is quite clear now. Except one thing, which is actually the deep reason of my initial problem :
Dave said : >Don't use objects and new/delete when you don't have >globals. Realistically, you won't be doing much when you don't have >globals, so you don't really need a lot of C++ there.
This is not true. For instance, and this is my problem, the application preferences are simple byte arrays. So to store information, I have to compact data (strings, long etc.) into byte stream. Note that it is the same to store data in the database, with DM functions.
As compacting data into byte stream is really an interesting feature, (C++ help me to REUSE) I build a class called "record" that is capable of holding fields, keeping track of the byte length, type of data and data itself. This class is then subclassed for 2 different uses, the first is called "prefman" which is capable of storing bytes into prefs, and "dbman" which is capable of storing data into dabatase.
This way , my "record" class is a good time saver for me. I can imagine using it also for serial communications etc.. but I must ensure that it keeps also byte order and character encoding.
When app is launched for sysAppLaunchCmdFind, then I dont have globals. But I still want to access my prefs... So "record" class and "prefman" class are very usefull.
To implement the same feature without classes, I have to declare all variables that are ENCAPSULATED in my objects (I make a structure), then call the good function giving it the structure locally allocated, etc. I loose many advantages of C++. I also have to do the same if I need to access the database. The "record" class will have to be broken into multiple functions and I don't know how easy it would be to use them in several environments like pref, dm and serial. (quite sure it won't!)
Well this is one example and I'm sure it is not the only one. Now thanks to your advice, I know how to use new/delete safely, and I now that classes that may be used in non global environment cannot have virtual or static members.
Thanks a lot.
-- Riccardo Cohen
Articque Les Roches 37230 Fondettes France web = http://www.articque.com tel: +33 02 47 49 90 49 fax: +33 02 47 49 91 49
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
