C++ Vector Class

Started by
24 comments, last by Moomin 16 years, 1 month ago
I'm actually not certain about this, but doesn't operator precedence still apply to overloaded operators?

If so, it adds a whole other can of worms to choosing symbols that not only make sense, but preserve proper precedence too. I can see incorrect precedence ordering being the source of rather nefarious bugs...

throw table_exception("(? ???)? ? ???");

Advertisement
Quote:Original post by Ravyne
I'm actually not certain about this, but doesn't operator precedence still apply to overloaded operators?


It does, or better yet, should (with C++ you never know).

It's still a can of worms.

Quote:Original post by MARS_999
As always JYK, I appreciate what you have to say. I agree when you work in a large project or plan on selling some library standards should be implemented. But for someone who is doing this as a hobby or plans on using it for themselves use whatever flips your trigger.


The only problem with this is when you take the accepted meaning of something, change it fundimentally and THEN ask for help from other programmers they aren't going to have a clue wtf is going on.

End of the day I honestly don't care, but at the same time I strongly recommend against anyone using such a system because it's insane and you effectively cut anyone else out from being able to help you out with problems in your code.

Also, you never said 'imo' you stated "So this is even cleaner yet", a definitative statement which, as statements go, is incorrect, as it's not 'cleaner' for the stated reason that it goes against already accepeted concepts and usage for the operators (one of the unwritten rules of operator overloading is 'dont change the meaning' [paraphased] as they should really do what people expect).

"imo" is no cover for simply bad advice...
Quote:Original post by phantom
Quote:Original post by MARS_999
As always JYK, I appreciate what you have to say. I agree when you work in a large project or plan on selling some library standards should be implemented. But for someone who is doing this as a hobby or plans on using it for themselves use whatever flips your trigger.


The only problem with this is when you take the accepted meaning of something, change it fundimentally and THEN ask for help from other programmers they aren't going to have a clue wtf is going on.

End of the day I honestly don't care, but at the same time I strongly recommend against anyone using such a system because it's insane and you effectively cut anyone else out from being able to help you out with problems in your code.

Also, you never said 'imo' you stated "So this is even cleaner yet", a definitative statement which, as statements go, is incorrect, as it's not 'cleaner' for the stated reason that it goes against already accepeted concepts and usage for the operators (one of the unwritten rules of operator overloading is 'dont change the meaning' [paraphased] as they should really do what people expect).

"imo" is no cover for simply bad advice...


Maybe you should read more carefully. Go back and read the ending of my post. It says... "But that's me." Correct!
Quote:Original post by MARS_999
Maybe you should read more carefully. Go back and read the ending of my post. It says... "But that's me." Correct!


That reads about as cleanly as your code.
Common mathematical notation for the cross product is either "x"(times) or "^". If your code is properly documented then is there any reason as to not overloading these operators? (Assuming they would otherwise have no meaning.)

As for the constructor from the source of the original post i'd be tempted to write it with constructor initialization lists, as it seems cleaner to me but I suppose its just preference.
Vector3D(float x, float y, float z) : x(x), y(y), z(z){}

This topic is closed to new replies.

Advertisement