0
我在我处理这个功能一些传统代码(在C++)发现为什么编译器不能捕获这个函数,它有什么作用?
Vec3d Minimum()
{
if(this->valid)
{
return minBB;
}
else
{
return NULL;
}
}
其中Vec3d是一个对象,它是基本上具有x,y,z和一些运营商一个结构重载(代码如下) 。
AFAIK,你不能为一个用户定义的对象返回一个0 ......或者是否有一些我不知道的自动转换为零?这仅仅是出于好奇:P
由于
class Vec3d
{
public:
double x,y,z;
/// \brief Default constructor initializes x and y to 0
Vec3d();
/** \brief Constructor initializies vector to input parameters x and y and z
*
* \param x Double value that initializes x value of vector
* \param y Double value that initializes y value of vector
* \param z Double value that initializes z value of vector
*/
Vec3d(double x, double y, double z);
/** \brief Copy constructor
*
* \param v Pointer to another vec3i with which to initialize current vec3i
*/
Vec3d(Vec3d* v);
/**\brief Sets a vector (already instantiated) to the input parameters (x,y,z)
*
* \param x Double value that initializes x value of vector
* \param y Double value that initializes y value of vector
* \param z Double value that initializes z value of vector
*
* This method is just so you can change the value of an already instantiated vector
*/
void set(double xi, double yi, double zi);
const Vec3d operator -(const Vec3d &other) const;
const Vec3d operator +(const Vec3d &other) const;
const Vec3d operator *(const double num) const;
const double operator *(const Vec3d &other) const;
const Vec3d operator /(const double num) const;
double magnitude();
};
呵呵,我没有看到构造函数的那部分哈哈。感谢您指出,我现在感到很蠢:P我会尽快接受答案,等待3分钟。 而且代码很糟糕。你没有看到它的一半......我完全在dailywtf上发布了一些,但我觉得教授会抓住我或什么哈哈。 – Xzhsh 2010-08-16 00:07:25
从不觉得愚蠢,更愚蠢的是,如果一个人不问 – 2010-08-16 00:35:12