I rewatched it, but there's no error
#include <iostream>
using namespace std;
class Vector2
{
public:
Vector2(float _x = 0.0f, float _y = 0.0f) : x(_x), y(_y) {}
float Magnitude() { return (float)sqrt(x * x + y * y); }
private:
float x{ 0 };
float y{ 0 };
};
int main()
{
Vector2 a;
Vector2 b{ 3,-3 };
Vector2 c{ numeric_limits<float>::max(),numeric_limits<float>::max() };
cout << a.Magnitude() << '\n';
cout << b.Magnitude() << '\n';
cout << c.Magnitude() << '\n';
}
© 2024 OneMinuteCode. All rights reserved.