Answer to Question #21873 in Molecular Physics | Thermodynamics for kenneth david
using namespace std;
int x, y;
void SetPosition(int x, int y)
this->x = x;
this->y = y;
/* Using 'protected' inheritance specifier.
Public and protected members of the parent class become protected.
Private members stay private */
class Rectangle : protected Shape
void SetName(string name)
/* The child class has access
to the public fields of the parent class */
this->name = name;
void Move(int delta_x, int delta_y)
/* We have also access to the protected fields of the parent class */
this->x += delta_x;
this->y += delta_y;
//this->unused = '$'; //this is wrong
/* The line below causes compilation error
because SetPosition is a protected method */
Need a fast expert's response?Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!