Question: AX 0 8 C + + : string toString ( ) { p 1 . toString ( ) + to

AX08
" C++
: string toString(){ p1.toString()+"" to ""+ p2.toString(); }()
2
(-
MoveBy (int deltaX, int deltaY) Segment x (deltaX) y (deltaY)
Segment::
:
#
#include
std
{
:
int x =0;
int y =0;
:
(){}
(int xVal int yVal){
moveBy(xVal, yVal)
}
string toString(){
_(x)+""""+ to_string(y)
}
void moveBy(int xVal, int yVal){
x += xVal;
y += yVal;
}
};
{
:
string toString(){ p1.toString()+"" to ""+ p2.toString(); }()
//
//YOUR_CODE_BELOW
//YOUR_CODE
void moveBy(int deltaX, int deltaY)// xVal yVal
{
p1->moveBy(deltaX, deltaY)
p2->moveBy(deltaX, deltaY)
}
//
(*p1*p2)
{
this->p1= p1;
this->p2= p2;
}
:
*p1
*p2
//YOUR_CODE_ABOVE
//
};
int main()
{
A(00)
B(4,4)
s1(A, B)
cout << s1.toString()<< endl;
s1.moveBy(1,1);
cout << s1.toString()<< endl;
s1.moveBy(0-2)
cout << s1.toString()<< endl;
}
"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!