Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » LoadFromFile, StoreToFile and Serialize
Re: LoadFromFile, StoreToFile and Serialize [message #28969 is a reply to message #28964] Wed, 29 September 2010 17:33 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1792
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

281264 wrote on Wed, 29 September 2010 13:59

1.- what is the actual difference between creating an object vs working with a temporary instance? Are there other more meaningful implications? What do you do in your applications?

Well, in both cases you create an object, the only difference is the syntax. E.g.:
class something{
    something(){...}
    ...
}
main(){
    something s; //this creates variable of type something (the call to the constructor is implicit)
    something(); //this is like calling a function, which returns object of type something 
                 //(or you can think of anonymous object - it exist, you just don't know how is it called)
    something t=something(); //you can either store it in variable of appropriate type
    something().Run(); //or call some of its methods (but in this case you didn't save
                       //the reference to the variable anywhere so you have no way to access it later)
}
I personally use whatever is shorter. In simple cases, where I just need to create the window and Run() it then "mywin().Run()" is totally sufficient. But when I need to access it more times, then I have to use the longer syntax: "mywin mw; mw.SetSomething();mw.Run();...".

281264 wrote on Wed, 29 September 2010 13:59

2.- To save/retrieve application’s data/config/etc..is the combination of mentioned functions the best choice? Are there other options available?
There is many options. Serialization is IMHO the simplest, as it requires only to implement Serialize(), which is very simple thanks to overloaded operator %. What is actually the best choice depends a lot on what you intend to do. For example to store window position or state of the application (e.g. what document is opened), the binary serialization is great. But if you want to save configuration, it is a good idea to make it human readable. For this you can either use Xmlize functions available in U++, or if you prefer plain text there are some classes to help you with this here on the forum. The final decision what format to use is always up to the designer of the application Wink

Honza

[Updated on: Wed, 29 September 2010 17:37]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MultiThreads and GLCtrl
Next Topic: Metrowerks Code Warrior
Goto Forum:
  


Current Time: Mon Aug 25 00:56:21 CEST 2025

Total time taken to generate the page: 0.05574 seconds