[語法] 二維陣列卡到陰

看板C_and_CPP (C/C++)作者 (aloha)時間16年前 (2009/09/22 16:59), 編輯推噓1(102)
留言3則, 3人參與, 最新討論串1/1
我利用vector的方式建立了陣列 vector<vector<int> > absorption(gridSize_t, vector<int>(gridSize_w)); vector<int>volume(gridSize_t); vector<vector<int> > Source(gridSize_t, vector<int>(gridSize_w)); vector<vector<int> > fluence(gridSize_t, vector<int>(gridSize_w)); 我想把這四個陣列都丟進函式裡面,我也希望陣列裡頭的值 跟著變動 我的函式是這樣寫的 void grid(struct photon &a ,double *ab,double *v, double *s,double *f, double &out) { double r =sqrt((a.x)*(a.x)+(a.y)*(a.y)); int i=r/dr; i++; int j=a.z/dz; j++; if (r>width) { out=out+a.weight*(ma/(ma+ms));} else { ab[j][i]=ab[j][i]+a.weight*(ma/(ma+ms)); v[i]=(2*i+1)*pi*dr*dr*dz; s[j][i]=a[j][i]/(photon_number*v[i]); f[j][i]=s[j][i]/ma; } } 跑出來問題是 can not convert `std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >' to `int*' for argument `2' to `void grid(photon&, int*, int*, int*, int*, double&)' 冏了 函式 & 陣列 外加卡到陰 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.174.168

09/22 17:19, , 1F
我覺得錯誤訊息寫得很清楚啊 你參數傳錯了
09/22 17:19, 1F

09/23 00:56, , 2F
你才卡卡卡 卡到陰吧 你想幹麻阿???
09/23 00:56, 2F

09/23 12:23, , 3F
哈~當然是我卡到陰 不然怎麼掛掉
09/23 12:23, 3F
文章代碼(AID): #1Ak97WjW (C_and_CPP)
文章代碼(AID): #1Ak97WjW (C_and_CPP)