调用重载的运算符函数

时间:2015-11-26 21:06:17

标签: c++-cli

我有重载功能

 Vector3D^ Vector3D:: operator + (Vector3D^ toAdd)  // Adding 2 vectors
{
    Vector3D^ temp = gcnew Vector3D();
    temp->x = x + toAdd->x;
    temp->y = y + toAdd->y;
    temp->z = z + toAdd->z;
    return temp;
}

但每当我打电话

double x1 = Convert::ToDouble(txtAx->Text);
double x2 = Convert::ToDouble(txtBx->Text);
double y1 = Convert::ToDouble(txtBx->Text);
double y2 = Convert::ToDouble(txtBx->Text);
double z1 = Convert::ToDouble(txtBx->Text);
double z2 = Convert::ToDouble(txtBx->Text);

Vector3D vectorA(x1, y1, z1);
Vector3D vectorB(x2, y2, z2);
Vector3D temp;

temp = vectorA + vectorB;

我得到一个no运算符匹配这些函数错误。每个网站都建议这样做。

0 个答案:

没有答案