Good Design for Initialization of Static Array
Posted
by
jplot
on Stack Overflow
See other posts from Stack Overflow
or by jplot
Published on 2012-09-09T00:19:19Z
Indexed on
2012/09/09
3:38 UTC
Read the original article
Hit count: 106
I have a question regarding good design in C++. I have a class A
, and all objects of this class use an integer array of constant values (they should share the same array, as their values are constant). The array needs to be computed (just once) before any object A.
I thought about having another class B
which contains the integer array as a static member, an init()
method which would fill this array according to some formula and a static boolean flag initialized
(if this variable if true then the init()
method would do nothing), but I'm not sure this is the best way to solve my design issue.
So my question is, what would be a good design/way to accomplish this ?
Thanks in advance.
© Stack Overflow or respective owner