F
Frederiek
Hi,
When modifying a data member in a class declaration, the static keyword
specifies that one copy of the member is shared by all instances of the
class.
Does that mean that the address of the data member is the same for
every instance of that class? I would expect so, but I noticed
something that makes me doubt a little.
What happens for example with the address of a static data member, that
uses in fact a type as specified in the argument list of a template
class?
An example:
template <class TYPE>
class MyClass
{
static MyClass<TYPE> *ptr;
};
For every instance of this class
- will there be only one address where the value of ptr is stored?
- or will there be provided one ptr data member storage for each type
of TYPE?
- or does every instance, in this case, get its own static data member
storage?
Kind regards,
Frederiek
When modifying a data member in a class declaration, the static keyword
specifies that one copy of the member is shared by all instances of the
class.
Does that mean that the address of the data member is the same for
every instance of that class? I would expect so, but I noticed
something that makes me doubt a little.
What happens for example with the address of a static data member, that
uses in fact a type as specified in the argument list of a template
class?
An example:
template <class TYPE>
class MyClass
{
static MyClass<TYPE> *ptr;
};
For every instance of this class
- will there be only one address where the value of ptr is stored?
- or will there be provided one ptr data member storage for each type
of TYPE?
- or does every instance, in this case, get its own static data member
storage?
Kind regards,
Frederiek