[quote name='King_DuckZ' timestamp='1306365312' post='4815827']
I already considered making free functions, but I really liked to have everything in my classes.
This is contrary to what's generally recommended, I believe. (
Here is an article on the topic you might want to read.)
[/quote]
Very interesting reading, I'll be certainly be coding differently after understanding it. Thanks a lot!
Why is the possibility of accessing the base class harmful? I can't think of any way it could cause problems, and I think it's very unlikely that you can find a way to share the functions without an accessible base class.
Here's my attempt. The base class is accessible, but I don't really see any problem with this.
Also, this has the advantage of not requiring any type casting.
P.S., How can your cross function be common? Cross products aren't even defined except in 3 and 7 dimensions.
I wanted my vector classes to have .x, .y and so on, and not .x(), .y() etc, so each specialization declares its own properties (I know I wrote getters in my post, it was just that I felt it was not important to show my point). I can still put the operator[] in the base class after the due refactoring, but at this point I will decide after reading jyk's link. And yes, probably making public inheritance is acceptable.
About the cross product yeah, my bad... that's what I get for posting at 2am :/ Although it can be handy to have a cross on 2D vectors that are zero-extended to 3D, but it's not really what I meant to do... nor to develop some 7D game
Well, thanks everyone for the hints!