My question is actual two fold. I am going through this tutorial https://www.youtube.com/watch?v=6y0bp-mnYU0 and at 1:07:45, he talks about using the override keyword when defining a virtual fucnction of an abstract class. I kept my classes declaration and definintion in different files. When I try to use override in my definition, it gives me the "'override' specifier illegal" on function definition on Visual Studio 2019. Why is this?
include "Circle.h" include "Shape.h"
double Circle::Area() override {
return 3.14159 * pow((width / 2), 2);
}
Also, what does this code snippet do? I am new to c++:
Circle::Circle(double width) : Shape(width) {
}
Why is circle using a constructor from an abstract class? Is this even possible? What does the : Shape(width) do.
This is what "Shape" class looks like:
class Shape
{
protected: //means that inherited classes will be able to access as long as it is part of protected
double height;
double width;
public:
static int numofShapes;
Shape(double length);
Shape(double height, double width);
Shape();
Shape(const Shape& orig);
virtual ~Shape();
//Setters and getters for privat mems
void Setheight(double height);
double Getheight();
void Setwidth(double height);
double Getwidth();
static int Getnumofshapes();
virtual double Area() = 0; //makes it an abstract base class
// private: only class code