For instance:
InitEmployee()
{
vector<Employee> employeeList = {
Employee("Clark Kent",0),
Employee("Bruce Wayne",1),
...
Employee("Hal Jordan",65535)
}
}
I cannot request a file or database, since this program must be in one executable file, so all persistent data must be hard-coded. I actually use boost multi_index_container to quickly search by name and id, but for simplicity I used the vector here as an example. The problem is that I cannot have as many (2 ^ 16) constant data in one function without. Is there a better way to initialize this list without splitting a function?
I am using VC12. Thank!
Update
See the selected answer. As mentioned, using static will force it to use data, not the stack. This is what I came across:
InitEmployee()
{
static Employee employeeList[] = {
{"Clark Kent",0},
{"Bruce Wayne",1},
...
{"Hal Jordan",65535}
}
vector<Employee*> employeeVec;
int count = sizeof(employeeList) / sizeof(Employee);
for (int i = 0; i < count; i++)
{
employeeVec.emplace(&employeeList[i]);
}
}
, Employee , c-, . , , - , , ! multi_index_container!