Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

lass point public: / Constructor; * @param initial_ x the x coordinate of the point * @param initial_y the y coordinate of the point *

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

lass point public: / Constructor; * @param initial_ x the x coordinate of the point * @param initial_y the y coordinate of the point * @pre None * @post sets the point to(initial_x, initial_y)*/ point(double initial x=0.0, double initial y=0.0 ); I MODIFICATION MEMBER FUNCTIONS* / I moves a point to a new location I@ param x _amount the amount to move along the x axis I@ param y_amount the amount to move along the y axis I* @pre None I @post The point has been moved by xamount along the x axis / and by y __amount along the y axis. / void shift(double xamount, double y __amount); rotates the point clockwise 90 degrees around the origin /* @pre None /* @post The point has been rotated clockwise 90 degrees around I the origin.*/ void rotate90( / / CONSTANT MEMBER FUNCTIONS*/ /** returns the x coordinate of the point. /*@pre None /* @post The value returned is the x coordinate of the point. double get_ x() const { return x;} I returns the y coordinate of the point. /* @pre None /*@post The value returned is the x coordinate of the point. / double get_y( ) const { return y;} private: / coordinate of this point / double x; s stion 1 (5 points) Saved If we overload operator == for the class point as a nonmember function, which of the following implementations is correct? a) bool operator ==( const point\& p1, const point \& p2) \{ return (p1.x()==p2x())&&(p1.y()==p2y()); b) bool operator == (const point & p 1 , const point & p2) {r return (p1.get_ x()==p2.get_x())&&( p1.get_ y()==p2 get_y()); bool operator == (const point &p1, const point & p 2) return (p1x()==p2x())&&(p1.y()==p2y()); \} b) bool operator == (const point & p 1 , const point & p 2) \{ \[ \text { \} return (p1.get_ } \left.x()==p 2 \cdot \operatorname{get}_{-} x() ight) \& \&\left(p 1 \cdot \operatorname{get} y()==p 2 \cdot \operatorname{get} \_y() ight) \text {; } \] c) None of these estion 2 (5 points) we overload operator == for the class point as a member function, which of the ollowing implementations is correct? a) None of these answers b) bool operator == (const point\& p1, const point & p2) \[ \text { \{ return }(p 1 \text {.get_ } x()==p \text { 2.get_ } x()) \& \&(p 1 \text {.get_} y()==p 2 \text { get_ } y()) \text {; } \] c) bool point::operator ==( const point & p) \} return (x,y)==(p.x,p.y) d) bool point::operator ==( const point & p) \{ return (x== p.get_ x())&&(y== p.get_ y())

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

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions