Wur*_*rmD 3 c++ operator-overloading
我不明白编译错误 C2676
对于下面的代码
#ifndef __VEC_3D_H__
#define __VEC_3D_H__
#include <vector>
#include <cmath>
namespace Internal
{
/** very simple 3D vector/ point */
class Vec3D
{
public:
float mX;
float mY;
float mZ;
/// null constructor
Vec3D(void) {}
/// construct from data
Vec3D(float x, float y, float z) : mX(x), mY(y), mZ(z) {}
inline friend std::ostream& operator<< (std::ostream& os, const Vec3D& v)
{
os << "(" << v.mX << ", " << v.mY << ", " << v.mZ << ")";
return os;
}
};
}
#endif
Run Code Online (Sandbox Code Playgroud)
我在另一个类中放置了一个功能相同的代码,它编译并运行良好。这里有什么问题?
EDIT1:将 BOBVec3d 更正为 Vec3D,是一个错字
EDIT2:删除using namespace Internal;,将它放在头文件中确实是失败的