So my problem is that I need to create a data table in which each column is a vector that contains some sort of data that is read in from a file. The problem is that the table could have any dimensions, and each column can be one of many types (string, int, double, etc.). I would like to know if there is a way to create this object that I want. Right now I am attempting to do it using a template class:
The problem with this is that to instantiate a vector of asciiColumns I have to specify the type that asciiColumn should contain, and that defeats the purpose.
Any help with this solution or other proposed solutions would be much appreciated.
Another way would be to create a base value class and derive value types from it. The vector would store pointers to base types. This would require you to manage the allocation and destruction of the elements.
Code:
struct Value
{
};
struct Int_Value : public Value
{
int value;
};
struct Double_Value : public Value
{
double value;
};
struct String_Value : public Value
{
std::string value;
};
vector<Value *> vector_of_values;
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
Bookmarks