Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Fails:
- .h:
- namespace IBDS
- {
- public:
- friend Vector3D operator ^ (const Vector3D& a, const Vector3D& b);
- }
- .cpp:
- Vector3D IBDS::operator ^ (const Vector3D& a, const Vector3D& b)
- {
- return Vector3D ( a.v[1]*b.v[2] - a.v[2]*b.v[1],
- a.v[2]*b.v[0] - a.v[0]*b.v[2],
- a.v[0]*b.v[1] - a.v[1]*b.v[0]);
- };
- => /ibds/Math/Vector3D.cpp:204: error: 'IBDS::Vector3D IBDS::operator^(const IBDS::Vector3D&, const IBDS::Vector3D&)' should have been declared inside 'IBDS'
- This works:
- .h:
- namespace IBDS
- {
- public:
- friend Vector3D operator ^ (const Vector3D& a, const Vector3D& b)
- {
- return Vector3D ( a.v[1]*b.v[2] - a.v[2]*b.v[1],
- a.v[2]*b.v[0] - a.v[0]*b.v[2],
- a.v[0]*b.v[1] - a.v[1]*b.v[0]);
- };
- }
- .cpp:
- // nil
Add Comment
Please, Sign In to add comment