Hey all,
        
        So here's a C++ question for you:

/* file1.c */
//global to file 1
static HtConfiguration *config = NULL;

/* function1 */
config = HtConfiguration::config();
-------------------------
/* file 2 */
/* function2 */
HtConfiguration *config = HtConfiguration::config();


These declarations are in two separate files.  When the functions are
called, both 'config' variables point to the SAME spot in global memory
where a HtConfiguration object lives.

If I change both declarations to

config = new HtConfiguration();

then the variables point to two different objects... (as is expected).

I've got Stroustrup's C++ book and I've looked up the scoping rules that
govern the '::' instantiation usage... kinda dense.  Anyone have a better
reference to what exactly is happening here?  (other than the obvious --
the object appears to be locally allocated but is really global in scope)

Any other interesting notes on this kind of usage?
Any advantage to doing it this way over the old-school C way of declaring
at the top of a file somewhere?

I also noticed that a call to config->~HtConfiguration() doesn't do much
to delete the object's contents.. there is no defined destructor in
Configuration.cc, just '{}' in the header file.

Thanks.

-- 
Neal Richter 
Knowledgebase Developer
RightNow Technologies, Inc.
Customer Service for Every Web Site



_______________________________________________
htdig-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/htdig-dev

Reply via email to