Final answer:
Declare and assign a new MovingBody object to a pointer named myMovingBody, call Read() to read fields, call Print() to output fields values, and then delete the object to free memory.
Step-by-step explanation:
To declare and assign a pointer myMovingBody with a new MovingBody object and use its methods, you can follow these steps in the main function:
- Declare the pointer and assign it with a new object:
- MovingBody* myMovingBody = new MovingBody();
- Call the Read() method to input the object's fields:
- myMovingBody->Read();
- Call the Print() method to output the values of the fields:
- myMovingBody->Print();
- Delete the object to release memory:
- delete myMovingBody;
Make sure to include necessary headers and use the appropriate namespace declaration.