Jump to content
  • Advertisement
Sign in to follow this  
_WeirdCat_

operator overload fail

This topic is 943 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 have 3 operators


 

t3dpoint<T> operator*(const t3dpoint<T> p) const  //operator cannot be overloaded
t4dpoint<T> operator*(const t4dpoint<T> p) const //operator cannot be overloaded
t4dpoint<T> operator*(const t3dpoint<T> p) const //operator cannot be overloaded

t3dpoint<T> operator*(const t4dpoint<T> p) const  //operator cannot be overloaded

[spoiler]

Description	Resource	Path	Location	Type
't3dpoint<_cType> Matrix44<T>::operator*(t3dpoint<_cType>) const' cannot be overloaded	DxcMatrix.h	/WiredNavalBattle/jni	line 140	C/C++ Problem
't3dpoint<_cType> Matrix44<T>::operator*(t4dpoint<type>) const' cannot be overloaded	DxcMatrix.h	/WiredNavalBattle/jni	line 166	C/C++ Problem
make.exe: *** [obj/local/armeabi-v7a/objs-debug/game/main.o] Error 1	WiredNavalBattle		 	C/C++ Problem
with 't4dpoint<type> Matrix44<T>::operator*(t3dpoint<_cType>) const'	DxcMatrix.h	/WiredNavalBattle/jni	line 82	C/C++ Problem
with 't4dpoint<type> Matrix44<T>::operator*(t4dpoint<type>) const'	DxcMatrix.h	/WiredNavalBattle/jni	line 109	C/C++ Problem
 

[/spoiler]

 
 
where
 
   template <class _cType> class  t4dpoint : public t3dpoint<_cType> {
   public:
_cType w;

how could i solve this without  changing * to lets say for one ^ and for second %

 

t4dpoint<T> operator*(const t4dpoint<T> p) const //operator cannot be overloaded
t4dpoint<T> operator*(const t3dpoint<T> p) const //operator cannot be overloaded

 

Edited by WiredCat

Share this post


Link to post
Share on other sites
Advertisement

Is the problem due to ambiguity?  Your t4dpoint is a t3dpoint (which does not really make much sense, I don't think inheritance is the right trick to use here) so when the compiler goes to resolve which function to call, it can't.

 

I'm going to go ahead and guess that you're making these binary operators member functions.  I recommend you start by taking the widely-accepted advice of always making binary operators non-member functions.  Then, move on and avoid using inheritance when it does not model an is-a relationship.  Your problems may just magically get solved.

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!