21. Add a constructor to the Point class that accepts another Point as a parameter and initializes this new Point to have the same (x, y) values. Use the keyword this in your solution.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 23SA
icon
Related questions
Question
Only Number 21
Section 8.3: Object Initialization: Constructors
17. What is a constructor? How is a constructor different from other methods?
18. What are two major problems with the following constructor?
public void Point (int initialx, int initialy) {
int x = initialX;
int y initialY;
}
19. (You must complete Self-Check Problem 7 before answering this question.)
Add a constructor to the Name class that accepts a first name, middle initial, and last name as parameters and
initializes the Name object's state with those values.
20. What is the meaning of the keyword this? Describe three ways that the keyword can be used.
21. Add a constructor to the Point class that accepts another Point as a parameter and initializes this new Point to
have the same (x, y) values. Use the keyword this in your solution.
Transcribed Image Text:Section 8.3: Object Initialization: Constructors 17. What is a constructor? How is a constructor different from other methods? 18. What are two major problems with the following constructor? public void Point (int initialx, int initialy) { int x = initialX; int y initialY; } 19. (You must complete Self-Check Problem 7 before answering this question.) Add a constructor to the Name class that accepts a first name, middle initial, and last name as parameters and initializes the Name object's state with those values. 20. What is the meaning of the keyword this? Describe three ways that the keyword can be used. 21. Add a constructor to the Point class that accepts another Point as a parameter and initializes this new Point to have the same (x, y) values. Use the keyword this in your solution.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning