E
emerth
I am curious about the structure of a C++ object.
Classes have methods, and data. Different instances of
a class will have their own data variables (yes, unless
I define a variable to be common, but let us say I did not
do that).
My question is this: does each instance have it's own
copy of the non-static methods?
Maybe this is a dumb question, but what motivates it is
this:
Say I have a class with a really huge complicated method
and I will be instantiating many, many objects of this class.
If each instance gets it's own copy of the huge method code,
then I might save some memory by modifying the method to
be a function (eg not a class method) and have only one
copy of it around.
Classes have methods, and data. Different instances of
a class will have their own data variables (yes, unless
I define a variable to be common, but let us say I did not
do that).
My question is this: does each instance have it's own
copy of the non-static methods?
Maybe this is a dumb question, but what motivates it is
this:
Say I have a class with a really huge complicated method
and I will be instantiating many, many objects of this class.
If each instance gets it's own copy of the huge method code,
then I might save some memory by modifying the method to
be a function (eg not a class method) and have only one
copy of it around.