Sign in to follow this  

+ operator

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I tried it but doesn't work
f:\visualc++6.0\myprojects\main\vector3.h(24) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information

Share this post


Link to post
Share on other sites
An internal compiler error means there's a bug in the compiler, not the code. Although why is the "friend" declaration there?

This works fine for me:

class CVector
{
public:
float x, y, z;
CVector(float _x, float _y, float _z) { x = _x; y = _y; z = _z; }
CVector operator+(const CVector& v2) const
{ return CVector(x+v2.x, y+v2.y, z+v2.z); }
};

This also works fine for me:

class CVector
{
public:
float x, y, z;
CVector(float _x, float _y, float _z) { x = _x; y = _y; z = _z; }
};

inline CVector operator+(const CVector& v1, const CVector& v2)
{
return CVector(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
}

Share this post


Link to post
Share on other sites
Well maybe i should try the inline...you see using binary operator +,-...etc is forbiden by the compiler unless you declare it as friend.i used that a few times without problems i can't see why it doesn't work now

Share this post


Link to post
Share on other sites

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this