Try to search your question here, if you can't find : Ask Any Question Now ?

Initialize vector with M elements of empty vectors c++

HomeCategory: stackoverflowInitialize vector with M elements of empty vectors c++
Avatarwillson asked 6 days ago

Setting m_data.resize(a_M) does work but I would like to know why this error occurred.

error: type 'vector<vector<double> >' does not provide a call operator

This is the beginning of a class SparseMatrix. I need to initialize the row number a_M and have each element be empty. The idea is for m_data(a_M) initialize m_data to have a_M rows of empty vectors, though the error above occurred.

class SparseMatrix
  SparseMatrix(int a_M, int a_N);
  unsigned int m_m, m_n;
  double m_zero;
  vector<vector<double> > m_data;
  vector<vector<int> >   m_colIndex;

SparseMatrix::SparseMatrix(int a_M, int a_N)
  m_m = a_M;
  m_n = a_N;
  m_zero = 0.0;

I am still new to C++ so it’s these little things that are hard to come by on the internet. I really appreciate the help!

1 Answers
Best Answer
AvatarAmit answered 6 days ago
Your Answer

3 + 14 =

Popular Tags

WP Facebook Auto Publish Powered By :