I have define a class which has complex vector members:
class Node
{
public:
Node(void);
GVector r;
vector <complex<double> > Uhat;
vector <complex<double> > dUhatdx;
vector <complex<double> > dUhatdy;
double rho,u,v,p;
//there are 4x3 derivatives to be calculated:
//dudx,dudy,dudz ; dvdx,dvdy,dvdz ; dwdx,dwdy,dwdz ; dTdx,dTdy,dTdz
double drhodx,drhody,drhodz;
double dudx,dudy,dudz;
double dvdx,dvdy,dvdz;
double dwdx,dwdy,dwdz;
double dpdx,dpdy,dpdz;
void Update();
void Nullify();
~Node(void);
};
In the main program I have:
Node node[Imax+1][Jmax+1]
I want to transfer only one row or column of this array to a function. How can I do this?
Well a c-style 2d array is still stored linearly, so there is no way other than to know the size of the "steps" from one to another. You would need to pass the pointer for the entire array and specify the size of the 2d array like so:
1 2 3 4
void foo(Node arr[][100], int size)
{
}
Or you could use templating in this case to allow any dimension:
1 2 3 4 5 6 7
template<unsignedint T>
void foo(Node arr[][T], int size)
{
}
In either case, inorder to get access to those values you're going to need to know the size of each "row".