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.

runMatrix is a member function of library, so you need to either
1) instantiate an object of that class and call it like libraryObj.runMatrix(...)
or
2) if the runMatrix is a static function, then call it like library::runMatrix(...).

sorry I forgot to remove the library:: bit. I have it correct in my code (ie ... = m_library.runMatrix("..")), but it still sais undefined reference!
Edit - If I create another function almost exactly like this, but have a 2d array of integers (i.e. int[5][5]), it works fine! If I replace the string with something else, like int, the result is the same.

This question has already been answered. Start a new discussion instead.