I am practicing my OOP and I have the following classes: Point and Circle. Specifically, Circle has a center Point, and a radius. Here is the relevant code:
Change the constructor the following way
Circle::Circle(const Point& center, double radius)
: center_pt( center ), radius_size( radius )
{
}
The problem is that if you will not call explicitly the constructor with parameters for class Point then the compiler tries to call the default constructor of the class to create data member center_pt of class Circle before you can assign the point within the body of the constructor of class Circle. But you did not define the default constructor of class Point and the compiler issued an error.
The other approach is indeed to define the default constructor for class Point that for example initilaizes a point with zeroes.
Take into account that by design of class Point you can not change data members coord_x and coord_y of a created object.Maybe you should redesign the class.