Question: Assign pointer myEngine with a new Engine object. Call myEngine's Read ( ) to read the object's fields. Then, call myEngine's Print ( ) to
Assign pointer myEngine with a new Engine object. Call myEngine's Read to read the object's fields. Then, call myEngine's Print
to output the values of the fields. Finally, delete myEngine. #include
using namespace std;
class Engine
public:
Engine;
void Read;
void Print;
~Engine;
private:
int power;
int duration;
;
Engine::Engine
power ;
duration ;
void Engine::Read
cin power;
cin duration;
void Engine::Print
cout "Engine's power: power endl;
cout "Engine's duration: duration endl;
Engine::~Engine Covered in section on Destructors.
cout "Engine with power power and duration duration is deallocated." endl;
int main
Engine myEngine nullptr;
your code here
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
