#include#include using namespace std; class Vector2D { public: double x, y; Vector2D(double x_val, double y_val) { x = x_val; y = y_val; } double Length() { return sqrt(x*x + y*y); } }; int main() { Vector2D v(3, 4); cout << v.Length() << endl; return 0; }
#includeBased on the use of Vector2D, I assume that this is a custom class created by the programmer and is not part of any package or library.#include using namespace std; class Vector2D { public: double x, y; Vector2D(double x_val, double y_val) { x = x_val; y = y_val; } double Length() { return hypot(x, y); } }; int main() { Vector2D v(-2, 5); cout << v.Length() << endl; return 0; }