When I have test data objects, or other static data objects such as SQL strings, I like to keep them out of application code. In Python, this is done with a separate source file and an import as shown below. How is static data organized and used C++?
(file: testdata.py)
x = Foo() (an object)
x.name = "Bar"
x.number = 123
..
(file: test.py)
import testdata.py
testObject1 = testdata.x
..
There are lots of possibilities. This also depends on what you’re trying to do (e.g. do you want the values to be editable after compiling or only before compiling?
As for the later, you could use a separate translation unit.
In some header file:
In one separate source file:
However, you could do the class/struct approach, too:
Header file:
Source file: