Thank you for your precious time.
With my limited understanding of C++, it seems that instead of directly defining an array of C++ functions, we need an array of pointers to functions.
This is the only way I know how to use a for loop in C++ to iterate over a family of functions. I am creating a map from the names of functions to functions as follows:
Code:
map<string,void (*)(string, vector<string> &, vector<vector<RAStruct > > & ) >map_FuncNamesToFuncs;
And once this map above is prepared and populated, finally I am able to iterate over the functionswith a for loop like this:
Code:
vector<string>::iterator end = vec_NamesOfAverageFunctions.end() ;
for(vector<string>::iterator itr=vec_NamesOfAverageFunctions.begin() ; itr != end; ++itr) {
// map_FuncNamesToFuncs[ (*itr) ]( vec_NamesOfKeyFilesForRandAcc[i] , vec_CoreSymbolInfo, vec_NamesOfSymbolFilesForMarkets[i] ) ;
map_FuncNamesToFuncs[ (*itr) ]( vec_NamesOfSymbolFilesForMarkets[i], vec_MarketSymbolList, vec_AllSymRecs ) ;
cout << "Executed avg function " << *itr << endl;
}
This works, but if there is a better way to access a family of functions, please let me know. In this case, the names of the functions that will be called can be written in a text file and the program that reads the text file can actually enable the map accordingly.
Thanks!!