float Vector3::nan = NAN;
-Vector3::Vector3()
-{
- elem[0] = elem[1] = elem[2] = 0.0F;
-}
-
-Vector3::Vector3(float a, float b, float c)
-{
- elem[0] = a;
- elem[1] = b;
- elem[2] = c;
-}
-
-Vector3::Vector3(const Vector3 &to_copy)
-{
- elem[0] = to_copy.elem[0];
- elem[1] = to_copy.elem[1];
- elem[2] = to_copy.elem[2];
-}
-
-Vector3& Vector3::operator= (const Vector3 &to_copy)
-{
- if( this != &to_copy ) {
- elem[0] = to_copy.elem[0];
- elem[1] = to_copy.elem[1];
- elem[2] = to_copy.elem[2];
- }
- return *this;
-}
-
float Vector3::operator[](int i) const
{
if (i >= 0 && i <= 2)
class Vector3
{
public:
- Vector3();
- Vector3(float, float, float);
- Vector3(const Vector3& to_copy);
- Vector3& operator= (const Vector3& to_copy);
+ Vector3() = default;
+ Vector3(float a, float b, float c) : elem{a,b,c} {}
+ Vector3(const Vector3& to_copy) = default;
float operator[](int) const;
void set(float a, float b, float c);
Vector3 unit(void) const;
private:
- float elem[3];
+ float elem[3]{};
static float nan;
};