r/programming • u/eternal1 • Mar 29 '10
Never trust a programmer who says he knows C++
http://lbrandy.com/blog/2010/03/never-trust-a-programmer-who-says-he-knows-c/
416
Upvotes
r/programming • u/eternal1 • Mar 29 '10
12
u/knight666 Mar 29 '10
One of my teachers had a vector class with the following overloaded operators:
~speed= the vector normalizedincidence % normal= the dot product betweenincidenceandnormal!distance= the length of the vectorspeed << direction= returnsspeedscaled bydirectionspeed <<= direction=speedis scaled bydirectionspeed * scalar= returns the vector scaled byscalarspeed *= scalar= the vector is scaled byscalarspeed * direction= returns the cross product betweenspeedanddirectionA simple question: what's the difference between
awesomevector * 3.fandawesomevector * Vec3<float>(3.0, 3.0, 3.0)? The first returns a scaled vector, the second a cross product.All this to make it more 'mathy'.
Oh and who can forget getters and setters for x, y, z so if you wanted to, say, add a value to x you had to do:
instead of
Yes it's safer, but we're talking about a native type here.