"pmastroianni" <pm**********@shelbrook.com> wrote in message
news:70**************************@posting.google.c om...
When a class is instantiated, will the ctor and dtor occupy memory?
IF ctor and dtor do occupy memory of an instantiated class where would
they be in memeory?
A good book should tell you this.
Member functions, including the constructor and destructor, obviously have
to exist "somewhere" (unless, I suppose, they do nothing, in which case an
optimizing compiler could remove them). Where they exists is entirely up to
the compiler and the operating system.
But member functions exist on a "per class" basis, not a "per instance"
basis. There's no reason to have copies of those functions lying around for
every instance of the class that your code creates. Each instance simply
refers to the same set of member functions.
Member data, obviously, needs to exist for every instance, because the
member variables likely take on different values for each instance. (At
least for non-static member data, that is.) But the functions are just sets
of instructions, and don't need separate copies.
-Howard