Language: C++

#include <iostream>
#include <vector>

using namespace std;

class Vector {
public:
    double x, y;
    
    Vector() {
        x = 0.0;
        y = 0.0;
    }
    
    Vector(double nx, double ny) {
        x = nx;
        y = ny;
    }
    
    void set(double nx, double ny) {
        x = nx;
        y = ny;
    }
    
    void setX(double nx) {
        x = nx;
    }
    
    void setY(double ny) {
        y = ny;
    }
    
    // ベクトルの大きさを求める
    double norm() const {
        return sqrt(x * x + y * y);
    }
    
    // 内積を求める
    double dot(const Vector& vec) {
        return x * vec.x + y * vec.y;
    }
    
    // 外積を求める
    double cross(const Vector& vec) const {
        return x * vec.y - y * vec.x;
    }

    // 余弦を求める
    double getCos(const Vector& vec) {
        double nor = norm() * vec.norm();
        if (nor == 0.0) {
            return 0.0;
        } else {
            return dot(vec) / nor;
        }
    }
    
    // 単位ベクトルを返す
    Vector getUnit() {
        Vector v;
        double mag = norm();
        if (mag == 0.0) {
            v.set(0.0, 0.0);
        } else {
            v.set(x / mag, y / mag);
        }
        return v;
    }
    
    void operator = (const Vector& vec) {
        x = vec.x;
        y = vec.y;
    }
    
    Vector operator + (const Vector& vec) {
        Vector v(x + vec.x, y + vec.y);
        return v;
    }
    
    Vector operator - (const Vector& vec) {
        Vector v(x - vec.x, y - vec.y);
        return v;
    }
    
    Vector operator * (const Vector& vec) {
        Vector v(x * vec.x, y * vec.y);
        return v;
    }
    
    Vector operator * (double f) {
        Vector v(x * f, y * f);
        return v;
    }
    
    Vector operator / (const Vector& vec) {
        Vector v;
        if (vec.x == 0.0) {
            v.setX(0.0);
        } else {
            v.setX(x / vec.x);
        }
        
        if (vec.y == 0.0) {
            v.setY(0.0);
        } else {
            v.setY(y / vec.y);
        }
        return v;
    }
    
    Vector operator / (double f) {
        Vector v;
        if (f == 0.0) {
            v.set(0.0, 0.0);
        } else {
            v.set(x / f, y / f);
        }
        return v;
    }
    
    void operator += (const Vector& vec) {
        x += vec.x;
        y += vec.y;
    }
    
    void operator -= (const Vector& vec) {
        x -= vec.x;
        y -= vec.y;
    }
    
    void operator *= (const Vector& vec) {
        x *= vec.x;
        y *= vec.y;
    }
    
    void operator /= (const Vector& vec) {
        if (vec.x == 0.0) {
            x = 0.0;
        } else {
            x /= vec.x;
        }
        
        if (vec.y == 0.0) {
            y = 0.0;
        } else {
            y /= vec.y;
        }
    }
};


class Polygon {
private:
    vector<Vector> vertex; // 頂点
public:
    // コンストラクタ
    Polygon() {}
    // 頂点配列を設定する
    void setVertex(const vector<Vector>& src) {
        vertex = src;
    }
    // 面積を計算する
    double calculateArea() {
        double sum = 0;
        for (int i = 0; i < vertex.size(); i++) {
            Vector vec1, vec2;
            if (i == vertex.size() - 1) {
                vec1 = vertex[0];
            } else {
                vec1 = vertex[i];
            }
            vec2 = vertex[i + 1];
            sum += vec1.cross(vec2);
        }
        return sum / 2.0;
    }
};

int main() {
    int n;
    cin >> n;
    vector<Vector> src;
    for (int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        Vector vec(x, y);
        src.push_back(vec);
    }
    
    Polygon poly;
    poly.setVertex(src);
    cout << poly.calculateArea() << endl;
}



Compiler output:
a.cc: In member function 'double Vector::norm() const':
a.cc:35:16: error: 'sqrt' was not declared in this scope
   35 |         return sqrt(x * x + y * y);
      |                ^~~~