So I've got Shape.h, Rectangle.h, Circle.h and main.cpp.
Shape.h got:
class Shape{
public:
Shape() {};
~Shape() { cout << "Destroy Shape."; };
virtual double getArea() = 0;
virtual double getCircumference() = 0;
};
Rectangle and Circle their respective code.
Now in main.cpp I do
Shape* newRectangle= new Rectangle(4, 8);
Shape* newCircle= new Circle(10);
All fine and dandy so far. Here's where I'm stumped. I know what I have to do, I just don't know HOW to do it.
I'm trying to write a function that checks if a Shape* Object belongs to Circle or not.
It goes something like this
if Shape* object belongs to Object-Type Circle, then
cout << "It's a Circle, bruh!";
else
cout << "Ain't a circle, yo!";
I started after googling with that:
void check(Shape & object){
Circle& checkObject = dynamic_cast<Circle&>(object);
}
The function in main will be called via:
check(*newRectangle);
check(*newCircle);
But I haven't got a clue how to go on :(. Any help and explanation is appreciated. Thank you!