I have this statement inside a function, that opens a XML file.
The XML file is opened every-time I call the function or is opened only in the first call??Code:static auto_ptr<Remote> remoteXML (Remote_("../config/remote_conf.xml"));
I have this statement inside a function, that opens a XML file.
The XML file is opened every-time I call the function or is opened only in the first call??Code:static auto_ptr<Remote> remoteXML (Remote_("../config/remote_conf.xml"));
I believe that it will be open every time.
static, in this case, will just make this function invisible to other program modules (e.g. files).
No, static variables inside functions don't make the functions static itself. This will be opened only in the first call.
And I wouldn't make it this way, since you will not be able to use this variable outside the function. It looks like the function does not open an XML file, but only creates an instance of object. You should consider returning a shared_ptr<Remote> so you will be able to open more than one file at a time.
Last edited by kmdv; 09-05-2010 at 09:01 AM.