Jump to content
  • Advertisement
Sign in to follow this  
mikfig

Error C2373 VS2008, doesn't make sense :(

This topic is 3059 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

Here is my source code: header file:
class Variant
{
public:

	typedef enum
	{
		INTEGER,
		FLOAT,
		BOOL,
		STRING,
		VECTOR2,
		VECTOR3,
		VECTOR4,
		MATRIX3X3,
		MATRIX4X4,
		NULL_VARIANT
	} TYPE;

	Variant()
		: m_VariantType(NULL_VARIANT)
	{}

	...

	float   operator[](int a_iIndex) const;
	...

private:
	...
};

implementation file:
...
float Variant::operator [](int a_iIndex) const
{
	if(a_iIndex > 15) // invalid index
		assert(false);
	else if(a_iIndex > 8) // can't be a matrix3x3 or vector
		assert(m_VariantType == MATRIX4X4);
	else if(a_iIndex > 3) // can't be a vector
		assert(m_VariantType == MATRIX3X3 ||
			   m_VariantType == MATRIX4X4);
	else if(a_iIndex > 2) // can't be a vector3 or vector 2
		assert(m_VariantType == VECTOR4	  ||
			   m_VariantType == MATRIX3X3 ||
			   m_VariantType == MATRIX4X4);
	else if(a_iIndex > 1) // can't be a vector2
		assert(m_VariantType == VECTOR3   ||
			   m_VariantType == VECTOR4	  ||
			   m_VariantType == MATRIX3X3 ||
			   m_VariantType == MATRIX4X4);
	else if(a_iIndex < 0) // invalid index
		assert(false);

	return m_FloatArray[a_iIndex];
}
...

Visual Studio 2008 is giving me error C2373: 'Variant::operator []' : redefinition; different type modifiers So it seems that if operator[] is defined twice then i would be able to comment out the definition for Variant::operator[] in the implementation file and I wouldn't get any linking errors if I used that function in another file. However, that is not the case. I researched this error and it seems to be a bug with Visual Studio 2008, but I'm really not sure. I installed SP1, hoping to have that "bug" be fixed. But the error still occurs. It seems that a lot of people had this issue when migrating code from previous version of VS to 2008, but I started this project in 2008. Does anyone see this cause of this error? Thanks, mikfig

Share this post


Link to post
Share on other sites
Advertisement
Uhhh! Now I feel like such an idiot. The problem was simply this:

I declared a function before the operator like this:

TYPE GetVariantType() { return m_VariantType; } const

however it obviously should have been declared like this:

TYPE GetVariantType() const { return m_VariantType; }


Stupid! Stupid! Stupid! :P lol

Thanks anyways,
mikfig

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!