Click to follow our Afritutor YouTube Channel, subscribe and click notifications and get updates on new learning videos
<=Back
John would like to use polymorphic class to determine the volume of a cone and cylinder. Write a C++ program that would use to:
- define class named threeD that has data members named radius and height, a parametric member function named set which is used to initialize the value of radius and height.
- implement two derived classes from threeD named cone and cylinder whose radius and height are 14cm and 8cm respectively.
The program should then output the volume for the cone and cylinder. Use pie as 3.142 and pointer appropriately. (7 marks)
Hint:
Volume of cone = 1/3*pie*r^2h
Volume of cylinder = pie*r^2h
 Viewed: 304 times For Better experience and learning,for video answers, after video ends playing, click next question in the questions list!!!
Share in: