Fitzpatrick, Joe wrote in message <1247@palm-dev-forum>...
>
>It seems to me that rather or not the constructor is trivial is not the
>point. The constructor will get called - *If* there is a reference to a
>method or member of the class somewhere in the application.
No ... the constructor is called if an instance of the object
is created. Seems to me that, although somebody before
mentioned that a "goal" of C++ is that user-created objects
behave like primitive types, well ... they don't. Primitives don't
have constructors.
Constructors are code that runs if the object is declared,
not only if it is referenced.
The linker ought to be aware of this behavior and treat
the constructor of a global object as "included" -- and
then anything -it- references would likewise be included.
The optimizer could try to be smart about the -contents-
of code included this way. For example, if the class has
an empty constructor, go ahead and chuck the global
object if there are no other references. Of course, then
there is the case of the -destructor- ... which would run
only when the object goes out of scope ... in the case of
a global object, that would be when the program is closing
down & cleaning up ... if the -destructor- had side effects,
the linker should not chuck the object. (Although anybody
that uses the destructor of a global object that has no other
use for cleanup code probably deserves what they get.)
IMO the linker is broken if it is not aware of the existance
and use of constructors and destructors of classes.
--
-Richard M. Hartman
[EMAIL PROTECTED]
186,000 mi/sec: not just a good idea, it's the LAW!
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html