Hello everyone!
I have a function to get data from a database. I want to put it into matrix of some sort so that I can have something like a spreadsheet (multiple columns and rows, depending on data). It needs to be dynamic. Ok code so far -
//---------------------------------------------------------------
template <typename T>
class dynamic_array
{
public:
dynamic_array(){};
dynamic_array(int rows, int cols)
{
for(int i=0; i<rows; ++i)
data_.push_back(std::vector<T>(cols));
}
...
};
//---------------------------------------------------------------
//---------------------------------------------------------------
dynamic_array<string>* runMatrix(string sql)
{
dynamic_array<string>* res = new dynamic_array<string>(nrow, ncol);
....
return res;
}
//---------------------------------------------------------------
//---------------------------------------------------------------
int main()
{
dynamic_array<Glib::ustring>* res= runMatrix("select name from albums");
/* access the matrix here */
delete res;
}
Now when I try to compile it sais
undefined reference to `runMatrix(string)'
What am I doing wrong? How can I return a 2-dimensional string matrix from a function? Thank you.