struct vect{
float x,y,z;
vect(float xx, float yy, float zz){
x=xx;
y=yy;
z=zz;
}
vect(){
x=0;
y=0;
z=0;
}
void normalize(){
float len = sqrt(x*x + y*y + z*z);
x = x/len;
y = y/len;
z = z/len;
}
vect operator-(const vect &other) const{return vect(x-other.x,y-other.y,z-other.z);}
};
bool tri_plane_x(vect *v1, vect *v2, vect *v3, vect *pos, float s){
//removed unnessecary code
if (vv1 != vv2){
vect dir = v2 - v1; // getting an error on this line
dir.normalize();
float d = (pos->x - v1->x)/dir.x;
hy[c] = d * dir.y + v1->y;
hz[c] = d * dir.z + v1->z;
c++;
}
//removed unnessecary code
}
有人知道为什么这不会编译吗?我如何重载函数是否有错误,或者这是因为我减去了两个指向 vect 的指针?
./exporter/main.cpp:74:19: error: conversion from ‘long int’ to non-scalar type ‘vect’ requested
这是与此行相关的编译器错误。(不包括整个日志,因为它只是代码中重复多次的相同错误)
我看不到“long int”的来源......使用指针时是否有另一种重载方式?