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 using namespace std;

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!