2-D vector as argument

Hi,

I declare a function as follows
 
double fun(vector<vector<double> > r2, int iMass[N],int iIndex)


then I declare a 2-D vector as follows

 
vector <vector <double> > vec;


I resize the vector appropriately using vec.resize(3) and vec[i].resize(3) etc...

now I try to pass the vector to fun as follows

 
DensityCalc(vec, iMass,0);


But I get the following error

52 C:\Documents and Settings\Tansel\My Documents\Saved\C++ Project\SPH.cpp no matching function for call to `DensityCalc(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >*, int[3], int)'

any help will be appreciated. thanks
It looks like your function is actually taking a pointer to a 2d vector or something. Check that your prototype and definition are consistent.
Oh dear turns out I used a template

template<int N>

above the declarations and didn't call the function
fun<3>(vec, iMass,0);

It works now.

By the way firedraco you also hit the nail on the head because my function declarations had one returning double and the other not, thank you. Time to go sleep I think

Also apologies for the double thread, browser got stuck for a bit.
Just delete the other one, there is a little box with an 'X' next to your name in the thread, you can use that to delete the thread.
Ahh yes thanks
Topic archived. No new replies allowed.