Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (15 points points each) Pointer Variables For question #1, do NOT use the auto keyword. a. (4 pts) Define a class ThreeDPoint having: Three

1. (15 points points each) Pointer Variables For question #1, do NOT use the auto keyword. a. (4 pts) Define a class ThreeDPoint having: Three private data members x, y, and z of type double, A default constructor which initializes all three data members to zero, AND A constructor taking three double parameters to initialize the three data members

b. (1 pt) Declare objects pt1 and pt2 of type ThreeDPoint with pt1 initialized to (1.0, 1.0, 2.0) and pt2 initialized to (-1.0, 0.0, 1.0).

c. (2 pts) Do we need to write a copy constructor for the ThreeDPoint class? Why or why not?

d. (2 pts) Write an accessor member function which returns the value of the data member x.

e. (1 pt) Write a mutator member function which takes a single double value and assigns that value to the data member y.

f. (1 pt) Write a statement to declare a pointer called ptPtr to a ThreeDPoint and initialize it to reference the pt1 (which you declared in part b).

g. (1 pt) Use ptPtr and the mutator written in part e to modify pt1s y data member to 4.0. Do NOT use the variable pt1 to access the mutator.

h. (1 pt) Write a statement to declare a vector of ThreeDPoint called myVector such that myVector has an initial size of one. You may assume has already been included.

i. (1 pt) Write a statement using ptPtr which you declared and initialized in part f to assign the value of pt1 to the first position (i.e., index 0) in myVector.

j. (1 pt) Write a statement to assign the value of pt2 to the second position (i.e., index 1) in myVector.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions