I'm getting a strange runtime error that I simply cannot comprehend. I'm making an object of my class Circle, which has the following default constructor:
Circle::Circle()
{
this->radius = 0;
this->center->setX(0);
this->center->setY(0);
}
The variables that are being are initialized are:
private:
double radius;
Point *center;
};
When I try to make an object of the class circle, I get a runtime error. Now I only get this error when the Point objectis declared dynamically. Is there anything wrong with my syntax? When I declare the Point in my Circle class like this instead:
Point center;
And initializes it like this instead:
Circle::Circle()
{
this->radius = 0;
this->center.setX(0);
this->center.setY(0);
}
It works. Why do I get these errors when I create the object dynamically? Can I not use two "->" like in the first example?
This is my first post, I hope this is not a too stupid question. Thanks in advance.
Point?