Mayb i knw whats the meaning of (Circle *) ?

There is class name Shape and Circle.
Shape is the base class while Circle is the subclass.
Shape declare the pointer *shapePtr;

I include the code so it wil explain everything:
1
2
3
4
5
6
 Shape *shapePtr;
Circle *circlePtr,c1(1,1.0)
shapePtr = &c1;
cout<<"Sahpe's area:"<<shapePtr->area();
circlePtr = (Circle*)shapePtr;
cout <<"Circle's circumference:" circlePtr->circumference();


I wan to know what is the meanning of this line circlePtr = (Circle*)shapePtr;
why is it necessary?
It's a C-style cast. It converts shapePtr from a pointer to Shape to a pointer to Circle
http://www.cplusplus.com/doc/tutorial/typecasting/
Topic archived. No new replies allowed.