Question
Assign pointer myCone with a new Cone object. Call myCone's Read() to read the object's fields. Then, call myCone's Print() to output the values of
Assign pointer myCone with a new Cone object. Call myCone's Read() to read the object's fields. Then, call myCone's Print() to output the values of the fields. Finally, delete myCone.
Ex: If the input is 26 48, then the output is:
Cone's radius: 26 Cone's height: 48 Cone with radius 26 and height 48 is deallocated.
#include
class Cone { public: Cone(); void Read(); void Print(); ~Cone(); private: int radius; int height; }; Cone::Cone() { radius = 0; height = 0; } void Cone::Read() { cin >> radius; cin >> height; } void Cone::Print() { cout << "Cone's radius: " << radius << endl; cout << "Cone's height: " << height << endl; } Cone::~Cone() { // Covered in section on Destructors. cout << "Cone with radius " << radius << " and height " << height << " is deallocated." << endl; }
int main() { Cone* myCone = nullptr; /* Your code goes here */
return 0; }
c++ and please please make it correct
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started