c++ - 二维数组指针double **&field经过这个转换 (void*&) field 是什么意思?
巴扎黑
巴扎黑 2017-04-17 15:33:12
0
1
949

本人非计算机专业的工科学生,今天读一个开源软件的源代码,遇到了一个奇怪的强制类型转换,代码如下:

void twoWayMPI::getData
(
    word name,
    word type,
    double ** const& field,
    label step
) const
{
    char* charName = wordToChar(name);
    char* charType = wordToChar(type);
    data_liggghts_to_of(charName,charType, lmp, (void*&) field, (char *)"double");
}

data_liggghts_to_of函数代码如下:

void data_liggghts_to_of(char *name,char *type,void *ptr,void *&data,char* datatype)
{
    //LAMMPS *lmp = (LAMMPS *) ptr;
    FixCfdCoupling* fcfd = (FixCfdCoupling*)locate_coupling_fix(ptr);
    fcfd->get_dc()->push(name,type,data,datatype);
}

getData函数调用data_liggghts_to_of函数时用了个奇怪的强制类型转换(void*&) field,我想问的问题是:

  1. 这个类型转换是把二维指针变量转换成了一维指针变量?

  2. getData函数在程序中的作用是为了给导入field指向的内存赋值,比如我在getData函数外定义了double* U,然后用getData(name, type, U, step)是为了给U指向的内存赋值;那么我想问的是经过(void&)U转换会对U产生什么影响?

巴扎黑
巴扎黑

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!