Hi, I'm pondering a design decision (which I find to be the hard part):
I have a y-by-x table where y and x are passed in by the user, and I'm looking for ideas on how to create a concise constructor that can populate the table. Perhaps with some kind of generic iterator? To be honest, I don't know iterators very well, just started reading through some standard library documentation. Further down the road, this table will be populated with rates that are stored in some external data source. I would like to be flexible on where the data comes from, so I don't want to tie it down to anything too specific. Here's what I'm thinking:
The first constructor can fill the table in with a constant value. The second constructor is what I am currently pondering. Is there (or can I define) some kind of generic enough pointer or iterator that I can use here without placing too many restrictions on the code that calls the constructor? Or, how would you fill this table? Perhaps introduce a template parameter for the iterator type? Better ideas?Code:class MyTable {
private:
vector<vector<double>> rates;
int startX, startY;
...
public:
MyTable(int startY, int lenY, int startX, int lenX, double fill = 0);
MyTable(int startY, int lenY, int startX, int lenX, Itor& it);
...
};