radiusValue and heightValue are read from input. Declare and assign pointer myCone with a new Cone object. Then, set myC

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

radiusValue and heightValue are read from input. Declare and assign pointer myCone with a new Cone object. Then, set myC

Post by answerhappygod »

radiusValue and heightValue are read from input. Declare andassign pointer myCone with a new Cone object. Then, set myCone'sradius and height to radiusValue and heightValue, respectively.
Ex: if the input is 24 40, then the output is:
Cone's radius: 24 Cone's height: 40
#include <iostream>using namespace std;
class Cone { public: Cone(); void Print();
int radius; int height;};Cone::Cone() { radius = 0; height = 0;}void Cone::Print() { cout << "Cone's radius: " << radius<< endl; cout << "Cone's height: " << height<< endl;}
int main() { int radiusValue; int heightValue; /* Additional variable declarations go here */ cin >> radiusValue; cin >> heightValue; /* Your code goes here */ myCone->Print(); return 0;}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply