E
Eric Lilja
Hello, I have a class in my program and there may be several objects around
of the class at any given time. The class has seven data members that
qualify for static linkage, but only one of them will have it value known
during compile time. The other six data members are basically pointer types
and can only receive meaningful values during runtime.
Right now I am using the constructor the give these static members their
values (they're initialized to NULL) but it feels wrong because that means
that for each object I create, I pass the same data for six variables. (I
also noticed I couldn't assign values in the initializer list, had to be in
the body.) So in the body of the constructor I have:
if(!m_static_data_member)
m_static_data_member = some_variable_passed_to_the_ctor;
* 6...
It doesn't feel elegant...what should I do?
/ Eric
of the class at any given time. The class has seven data members that
qualify for static linkage, but only one of them will have it value known
during compile time. The other six data members are basically pointer types
and can only receive meaningful values during runtime.
Right now I am using the constructor the give these static members their
values (they're initialized to NULL) but it feels wrong because that means
that for each object I create, I pass the same data for six variables. (I
also noticed I couldn't assign values in the initializer list, had to be in
the body.) So in the body of the constructor I have:
if(!m_static_data_member)
m_static_data_member = some_variable_passed_to_the_ctor;
* 6...
It doesn't feel elegant...what should I do?
/ Eric