다차원 배열을 가져야하는 클래스가 있습니다. 문제는 이러한 차원의 값이 다른 함수를 사용하여 클래스에서 계산되고 일부 공용 변수에 저장된다는 것입니다. 따라서 클래스 내의 다른 모든 함수는이 변수에 저장된 값을 읽을 수 있습니다. 함수의 정의는 다음과 같이이다 : max_ctrl_no
및 max_rep_no
그 public
변수는차원 크기가 분명하지 않은 경우 다차원 배열이 작동하도록 전달
double calcSS(double tfpairexp[][max_ctrl_no][max_rep_no])
. 와 나는 이런 식으로 함수를 호출 :
calcSS(tfpairexp);
을하지만 컴파일러는 함수의 정의에 오류가 있습니다. 그리고 그 vars 대신에 일정한 숫자를 넣으면 오류가 없습니다. 그러나 프로그램이 시작될 때의 차원을 알지 못합니다. 어떻게해야합니까?
업데이트
void tripleofgenes(int begind,int endind) {
for (int tf1=0; tf1<tfact; ++tf1)
{
for (int tf2=tf1+1; tf2<tfact; ++tf2)
{
double tfpairexp[cchips][max_ctrl_no][max_rep_no];
double w,d;
int ctrl_no;int c, ctr;
for (int j = 0; j < cchips ; j += c)
{
c = chips[j].crepls;
int ctrl_no=0;
for (int *p = chips[j].ctrl ; p && (ctr=*p)>=0; ++p,ctrl_no++) {
for (int k = 0; k < c; ++k)
{
double tf1exp=chips[k+j].vals[tf1].val-((chips[k+j].useextra) ? chips[ctr].extra[tf1] : chips[ctr].mean[tf1].val);
double tf2exp=chips[k+j].vals[tf2].val-((chips[k+j].useextra) ? chips[ctr].extra[tf2] : chips[ctr].mean[tf2].val);
tfpairexp[j][ctrl_no][k]=interactionFunc(tf1exp,tf2exp,1);
}
}
}
for (int tg=begind; tg<=endind; ++tg)
if (tf1!=tg){
calcSS(tfpairexp);
}
}
}
fclose(f);
}
double calcSS(double ***tfpairexp)
{
for (int row = 0; row <= 1 ; row++)
for (int col = 0; col <= 1 ; col++) {
int cond=0;
for (int j = 0; j < cchips; j += c) {
c = chips[j].crepls; // the number of replicants
int ctrl_no=0;
for (int *p = chips[j].ctrl; p && (ctr=*p)>=0; ++p,ctrl_no++) {
a = tfpairexp[j][ctrl_no][k];}
}
}
}
}
용액에 함수 특성을 변경하는
무효 tripleofgenes (INT begind, INT endind) {\t \t \t \t \t \t을 위한 {\t (INT TF2 TF1 = + 1; TF2
Pegah
@Pegah :이 함수와 calcSS() 모두 클래스에 정의되어 있습니까? – Nawaz
예. 둘 다 수업 중에 있습니다. – Pegah