Hi everyone, I have a virtual class "Shape.h" and four other classes inheriting from "Shape.h". The other classes are "Circle", "Ellipse", "Square" etc. The program is suppose to draw a shape as an output. The problem i'm having is that the virtual class "Shape.h" holds the properties like pen width, pen color and fill color and I don't know how to initialize the above properties since I can't declare an instance of the class "Shape.h". How can I do this?
You are probably wrong creating objects like Circle circle;.
You need to create pointer to abstract class and then assign pointer to newly created children.
Shape *figure = new Circle;
then you simply type figure-> to access inherited properties.
ps. dont forget to delete figure; after you are done