I am trying to understand the difference between having no body and having an empty body, as in these two functions:
void draw() const override;
void rotate(int angle) override {}
The complete code is shown below, where Shape is an interface and Circle an implementation of that interface.
#include<iostream>
#include<vector>
using namespace std;
class Point {
public:
double x() {
return x_coordinate;
}
double y() {
return y_coordinate;
}
private:
double x_coordinate, y_coordinate;
};
class Shape {
public:
virtual Point center() const =0;
virtual void move(Point to) =0;
virtual void draw() const =0;
virtual void rotate(int angle) =0;
virtual ~Shape() {}
};
class Circle: public Shape {
public:
Circle(Point p, int radius);
Point center() {
return c;
}
void move(Point to) {
c = to;
}
void draw() const override;
void rotate(int angle) override {}
private:
Point c;
int r;
};