传递多维数组到函数 [英] passing multidimensional arrays to function

查看:192
本文介绍了传递多维数组到函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的类中有一个方法,它使用3dimensional tfpairexp作为输入参数。我需要使用tfpairexp中的值。

I have a method in my class which uses a 3dimensional tfpairexp as input parameter. and I need to use the values in tfpairexp later.

void calctfpairexp (int tf1, int tf2, double tfpairexp[][2][3]) 
{

    int ctr,c;
    for (int j = 0; j < cchips && (c = chips[j].crepls); j += c)
    {
        int ctrl_no=0;
        for (int *p = chips[j].ctrl ; p && (ctr=*p)>=0; ++p,ctrl_no++)  {

            for (int k = 0; k < c; ++k)
            {

                tfpairexp[j][ctrl_no][k]=interactionFunc(2,3,1);
            }
        }
    }

}

我像这样调用类中的方法:
calctfpairexp(tf1,tf2,tfpairexp);
, tfpairexp在下一行。
,但编译器在此行中出现错误:

I call the method inside the class like this: calctfpairexp(tf1,tf2,tfpairexp); and I need to use values inside tfpairexp in next lines. but the compiler gives error in this line:

`calctfpairexp(tf1,tf2,tfpairexp);`

它说它找不到合适的calctfpairexp函数。任何想法?

It says that it can't find the suitable the suitable funciton for calctfpairexp. any idea?

推荐答案

我期望从该函数声明语法错误,因为数组param声明无效。您需要:

I would expect a syntax error from that function declaration, as the array param declaration is invalid. You need:

void calctfpairexp (int tf1, int tf2, double tfpairexp[][2][3])

数组索引在参数声明符后面出现

the array index stuff comes AFTER the param declarator

这篇关于传递多维数组到函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆