Language: C++

enum { OUT, ON, IN };

int contains(const polygon &P, const point &p)
{
    bool in = false;
    for (int i = 0, n = P.size(); i < n; ++i)
    {
        point a = P[i] - p, b = P[NEXT(i)] - p;
        if (imag(a) > imag(b)) swap(a, b);
        if (imag(a) <= 0 && 0 < imag(b))
            if (cross(a, b) < 0) in = !in;
        if (cross(a, b) == 0 && dot(a, b) <= 0)
            return ON;
    }
    return in ? IN : OUT;
}

struct convex_container{
    polygon pol;

    // Polygon MUST be in counter clockwise order
    convex_container(polygon p) : pol(p){
        int pos = 0;

        for (int i = 1; i < p.size(); ++i){
            if (p[i].imag() < p[pos].imag() ||
                (p[i].imag() == p[pos].imag() && p[i].real() < p[pos].real()))
                pos = i;
        }

        rotate(pol.begin(), pol.begin() + pos, pol.end());
    }

    bool contains(point p){
        point c = pol[0];

        if (p.imag() < c.imag() || cross(pol.back() - c, p - c) > 0)
            return false;

        int lo = 1, hi = pol.size() - 1;

        while (lo + 1 < hi){
            int m = (lo + hi) / 2;

            if (cross(p[m] - c, p - c) >= 0)
                lo = m;
            else
                hi = m;
        }

        return cross(pol[lo + 1] - pol[lo], p - pol[lo]) >= 0;
    }
};


Compiler output:
a.cc:3:20: error: 'polygon' does not name a type
    3 | int contains(const polygon &P, const point &p)
      |                    ^~~~~~~
a.cc:3:38: error: 'point' does not name a type; did you mean 'int'?
    3 | int contains(const polygon &P, const point &p)
      |                                      ^~~~~
      |                                      int
a.cc: In function 'int contains(const int&, const int&)':
a.cc:6:27: error: request for member 'size' in 'P', which is of non-class type 'const int'
    6 |     for (int i = 0, n = P.size(); i < n; ++i)
      |                           ^~~~
a.cc:8:9: error: 'point' was not declared in this scope; did you mean 'int'?
    8 |         point a = P[i] - p, b = P[NEXT(i)] - p;
      |         ^~~~~
      |         int
a.cc:9:18: error: 'a' was not declared in this scope
    9 |         if (imag(a) > imag(b)) swap(a, b);
      |                  ^
a.cc:9:13: error: 'imag' was not declared in this scope
    9 |         if (imag(a) > imag(b)) swap(a, b);
      |             ^~~~
a.cc:9:28: error: 'b' was not declared in this scope
    9 |         if (imag(a) > imag(b)) swap(a, b);
      |                            ^
a.cc:9:32: error: 'swap' was not declared in this scope
    9 |         if (imag(a) > imag(b)) swap(a, b);
      |                                ^~~~
a.cc:10:18: error: 'a' was not declared in this scope
   10 |         if (imag(a) <= 0 && 0 < imag(b))
      |                  ^
a.cc:10:13: error: 'imag' was not declared in this scope
   10 |         if (imag(a) <= 0 && 0 < imag(b))
      |             ^~~~
a.cc:10:38: error: 'b' was not declared in this scope
   10 |         if (imag(a) <= 0 && 0 < imag(b))
      |                                      ^
a.cc:11:17: error: 'cross' was not declared in this scope
   11 |             if (cross(a, b) < 0) in = !in;
      |                 ^~~~~
a.cc:12:19: error: 'a' was not declared in this scope
   12 |         if (cross(a, b) == 0 && dot(a, b) <= 0)
      |                   ^
a.cc:12:22: error: 'b' was not declared in this scope
   12 |         if (cross(a, b) == 0 && dot(a, b) <= 0)
      |                      ^
a.cc:12:13: error: 'cross' was not declared in this scope
   12 |         if (cross(a, b) == 0 && dot(a, b) <= 0)
      |             ^~~~~
a.cc:12:33: error: 'dot' was not declared in this scope
   12 |         if (cross(a, b) == 0 && dot(a, b) <= 0)
      |                                 ^~~
a.cc: At global scope:
a.cc:19:5: error: 'polygon' does not name a type
   19 |     polygon pol;
      |     ^~~~~~~
a.cc:22:29: error: expected ')' before 'p'
   22 |     convex_container(polygon p) : pol(p){
      |                     ~       ^~
      |                             )
a.cc:34:19: error: 'point' has not been declared
   34 |     bool contains(point p){
      |                   ^~~~~
a.cc: In member function 'bool convex_container::contains(int)':
a.cc:35:9: error: 'point' was not declared in this scope; did you mean 'int'?
   35 |         point c = pol[0];
      |         ^~~~~
      |         int
a.cc:37:15: error: request for member 'imag' in 'p', which is of non-class type 'int'
   37 |         if (p.imag() < c.imag() || cross(pol.back() - c, p - c) > 0)
      |               ^~~~
a.cc:37:24: error: 'c' was not declared in this scope
   37 |         if (p.imag() < c.imag() || cross(pol.back() - c, p - c) > 0)
      |                        ^
a.cc:37:42: error: 'pol' was not declared in this scope
   37 |         if (p.imag() < c.imag() || cross(pol.back() - c, p - c) > 0)
      |                                          ^~~
a.cc:37:36: error: 'cross' was not declared in this scope
   37 |         if (p.imag() < c.imag() || cross(pol.back() - c, p - c) > 0)
      |                                    ^~~~~
a.cc:40:26: error: 'pol' was not declared in this scope
   40 |         int lo = 1, hi = pol.size() - 1;
      |                          ^~~
a.cc:45:24: error: invalid types 'int[int]' for array subscript
   45 |             if (cross(p[m] - c, p - c) >= 0)
      |                        ^
a.cc:45:30: error: 'c' was not declared in this scope
   45 |             if (cross(p[m] - c, p - c) >= 0)
      |                              ^
a.cc:45:17: error: 'cross' was not declared in this scope
   45 |             if (cross(p[m] - c, p - c) >= 0)
      |                 ^~~~~
a.cc:51:16: error: 'cross' was not declared in this scope
   51 |         return cross(pol[lo + 1] - pol[lo], p - pol[lo]) >= 0;
      |                ^~~~~