My teacher included the lines below in one of our examples of casting. c
is an object of class Circle
which inherits from class Point
. In my search for an answer to the question "Can I cast an object of class Point
to type Circle
?" I found that he uses a different syntax than every website I've been on. The websites all use static_cast
and dynamic_cast
syntax. He won't be using static_cast and dynamic_cast on the test and I'm just wondering what he is using and how that operates.
Also, if you have an answer to whether I can cast a base object to a derived type, I thank you immensely.
output << "the center of the circle is at " << (Point) c;
// casting `Circle` object `c` with type `(Point)`, calls the first overloaded >stream insertion operator"