'finding where a point is in a shape

I'm using this prototype to find it

bool contains (double p_x, double p_y):

This method should determine whether or not the point specified by the coordinates in the parameter list is contained by the object in question. For example, the Circle class should compute the distance from the circle center to (px, py) for comparison to the radius of the circle; if the distance is less than the radius, then the point is contained by the shape and the method returns true. For a Square, assume that its reference point is the lower-left corner.

I do not get get how you would do this with circle since all I am given is a radius and for square all I am given is the side.

I've tried this for circle

bool Circle::contains (double p_x, double p_y){
    bool result = false;
    double dist = sqrt(pow(p_x, 2) + pow(p_y, 2) * 1.0);
    if (dist < radius){
        result = true;
    }
    return result;
}

and for square I really have no idea how.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source