2013-11-22 119 views
0

獲取這些錯誤在我的方程A和B,然後將其他錯誤是由是在calcit的結束時即時試圖把它傳遞給slopeitC++無效操作數和類型

 
    [Error] invalid operands of types 'int [3]' and 'int [3]' to binary 'operator*' 
[Error] invalid operands of types 'double' and 'int [3]' to binary 'operator*' 
[Error] invalid conversion from 'int' to 'double*' [-fpermissive] 
[Error] cannot convert 'int*' to 'double*' for argument '2' to 'void slopeit  (double*,double*,  int, double&, double&, double&)' 
 double slops[3], yints[3], boards[3]; 
    double yint15,yint20,yint25,slop15,slop20,slop25,rsq15,rsq20,rsq25; 
    double board; 

    void calcit (double tim15[], double tim20[], double tim25[], double tem15[], 
     double tem20[], double tem25[], int indx, int board,int temperature) 
    { 
double B; 
double A; 
double time; 
double slopsofslops; 
double yofslopes; 
double rsq; 
double yint15,yint20,yint25,slop15,slop20,slop25,rsq15,rsq20,rsq25; 
slopeit(tim15, tem15, indx, slop15, yint15, rsq15); 
slopeit(tim20, tem20, indx, slop20, yint20, rsq20); 
slopeit(tim25, tem25, indx, slop25, yint25, rsq25); 


yints[0]=yint15;    
yints[1]=yint20; 
yints[2]=yint25; 

boards[0]=15; 
boards[1]=20; 
boards[2]=25; 

slops[0]=slop15; 
slops[1]=slop20; 
slops[2]=slop25; 


indx = 3; 


time = pow(e,(temperature -B)/A); 
A = (slops * boards) + yofslopes; 
B = (yofslopes * boards) + yints; 

//Pass the values needed into writeit and finished 

slopeit(board, slops, indx, slopsofslops, yofslopes, rsq); 
     } 
    void slopeit(double x[], double y[], int n, double& m, double& b, double& r) 

回答

1

C++沒有任何內置操作符來操作數組,您必須創建自己的重載。

至於最後的錯誤,(或指向)int的數組與(或指向)數組double不一樣。您必須創建一個新的臨時double陣列,從int陣列填充它,並將double陣列傳遞給函數。

0

並且在您調用slopeit()時,您將使用板而不是板來調用第一個參數。板是雙層,板是雙層[]。

0

您需要將指針傳遞給函數按照您的定義

slopeit(board, slops, indx, *slopsofslops, *yofslopes, *rsq); 
     } 
    void slopeit(double x[], double y[], int n, double& m, double& b, double& r) 
0

[錯誤]類型 '詮釋[3]' 無效操作數和 'INT [3]' 二進制 「運營商*」

這錯誤是由於下面的行:

A = (slops * boards) + yofslopes; 

污水和板都是雙[3]型。 C++不能乘數組。您需要使用不同的類來支持它,例如Qt庫中的QVector3D類,否則您需要自行計算for循環中的產品(交叉產品或點積)。

[錯誤]類型 '雙' 和 'INT [3]' 的無效操作數的二進制 '操作符*'

這錯誤是由於下面的行:

B = (yofslopes * boards) + yints; 

yofslopes是雙重類型,板是雙[3]。同樣,C++不支持這些操作。它們是不兼容的類型。你可能會想要執行一個for循環來將每個元素乘以yofslopes(這是你在這裏之後?)。您也不能將一個數組添加到另一個數組。

目前還不清楚你想在這裏做什麼,因爲這裏是該行的單元分析:

double = (double * 3dVector) + 3dVector 

這沒有任何意義......

[錯誤]無效的轉換從 'INT' 到 '雙*'[-fpermissive]

這個錯誤是從以下行:

slopeit(board, slops, indx, slopsofslops, yofslopes, rsq); 

您有一個全局變量,稱爲board,它是double類型(不是double *)。然後你用同樣的名字定義了一個局部變量(在calcit的參數中),但是類型爲int(不是double *)。你不應該傳入一個整數,而是將它解釋爲一個指針而不顯式地轉換它。

[錯誤]不能轉換 '詮釋*' 到 '雙*' 的參數 '2' 到「無效 slopeit

不知道這是什麼錯誤指示。

希望這會有所幫助!

相關問題