Skip to main content
gamedev.net
🔒 Locked

Odd Anoying Runtime error

Started by CodeMaster000 2 replies 800+ views
Original Post
CodeMaster000
CodeMaster000
Here is my ( Actually Nehe's) VECTOR3D class. It is pretty strait forward.
    
class VECTOR3D
	{
	public:
		float v[3];

	const VECTOR3D operator=  (const VECTOR3D&	vec);
	const VECTOR3D operator+  (const VECTOR3D&	vec);
	const VECTOR3D operator+  (void);
	const VECTOR3D operator+= (const VECTOR3D&	vec);
	const VECTOR3D operator-  (const VECTOR3D&	vec);
	const VECTOR3D operator-  (void);
	const VECTOR3D operator-= (const float&	vec);
	const VECTOR3D operator*= (const float&	s);
	const VECTOR3D operator/= (const float&	s);
	const VECTOR3D operator*  (const float&   s);
	const VECTOR3D operator*  (const VECTOR3D&  vec);
	const VECTOR3D operator/  (float s);
	const bool	   operator== (const VECTOR3D&  vec);
	const bool     operator!= (const VECTOR3D&  vec);

	const float DotProduct(const VECTOR3D &vec);
	const float Length(void);
	const float SquaredDistance(VECTOR3D &vec);
	const VECTOR3D CrossProduct(const VECTOR3D& vec);
	const VECTOR3D Unit(void);
	void Normalize(void);
	void SendToOGL(void);
	void SetProperties(float x, float y, float z);

	VECTOR3D(void)
		{	memset(v[0], 0, sizeof(float[3]));	}
	VECTOR3D(float x, float y, float z);

	~VECTOR3D(void)
		{	}
	};
  

I keeps telling when I run the program that an error has occured in my program. I hit the debug option and it points me a part of the definition of the void SetProperties(float x, float y, float z);

      
void VECTOR3D::
	SetProperties(float x, float y, float z)
	{
		v[0]= x;
		v[1]= y;  //<------POINTS RIGHT HERE

		v[2]= z;
	}

    
It says it has an "Access Violation". [edited by - CodeMaster000 on January 9, 2003 6:38:09 PM]
Gladiator
Gladiator
Make sure that your pointers are valid and that you have allocated memory for all of them.

If you take the address of a vector and then try to use that reference later on in your program, make sure that the vector is still in scope.
CodeMaster000
CodeMaster000
How could I do that? Out of curiousity how would they leave the scope?
Gladiator
Gladiator
Debug. Stepping through your code should prove useful to figure our what''s going on.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.