我在 C++ 中无效的环境函数中创建了一个向量调用 nucleus 和 cell。然后我调用创建病毒点向量的病毒函数。然后我想在病毒调用的另一个函数中访问向量核和细胞。是否可以不通过病毒函数调用病毒?如果不是,最好的方法是什么?附上我的代码。先谢谢了。另外我没有在函数中添加所有代码......
struct point {
float x;
float y;
};
struct space{
point point1;
point point2;
point point3;
point point4;
};
int gelato(vector<point> & virus,int& times,int& iv, ofstream& data_file)
{
int a;
int b;
bool nc,cc,cmc;
for(int i =0; i<virus.size(); i++)
{
a = virus[i].x;
b = virus[i].y;
nc = nucleus_check(nucleus,a,b); // **Need to call vector cell and nucleus**
cc = cytoplasm_check(cell,a,b);
cmc = cell_membrane_check(cell,a,b);
}
}
int moves(char n)
{
int moved;
int trial;
if( n =='A')
{
moved = rand()%4;
}
else if(n=='B')
{
moved= rand()%3+1;
}
else if(n=='C')
{
trial= rand()%4;
if(trial ==1)
{
moves('C');
}
else
{
moved = trial;
}
}
else if(n =='D')
{
trial = rand()%4;
if(trial == 2)
{
moves('D');
}
else
{
moved = trial;
}
}
else if(n=='E')
{
moved = rand()%3;
}
return moved;
}
int v_move(vector<point>& virus, int& iv, ofstream& data_file)
{
gelato(virus,times,iv,data_file);
}
int rand_in(char a)
{}
void virus( ofstream& data_file)
{
v_move(virus, iv, data_file);
}
void cell_space(int r)
{
vector<point>cell;
}
void nucleus_space(int r)
{
vector<point>nucleus;
}
void environment() //**Where the vector nucleus and cell are created**
{
//cell
cell_space(16)
//nucleus
nucleus_space(4);
//cout<<"Environment"<<endl;
}
int main()
{
srand(time(NULL));
data_file.open("data.csv");
environment();
virus(data_file);
return 0;
}