2013-11-22 117 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

不知道这是什么错误指示。

希望这会有所帮助!

相关问题