I have the following UML showing how to create a class Point2D
.
I have created a header file for this class based on the UML:
#ifndef Point2D_h
#define Point2D_h
using namespace std;
// Header file for class Point2D
class Point2D
{
protected:
int x;
int y;
double distFrOrigin;
setDistFrOrigin();
public:
Point2D()
{
x = 0;
y = 0;
}
Point2D(int xInput, int yInput)
{
x = xInput;
y = yInput;
}
int getX();
int getY();
double getScalarValue();
int setX(int x);
int setY(int y);
};
#endif
However, I am confuse on the method setDistFrOrigin()
. The method is located inside the UML operation and it is a protected method. Am I suppose to group it with the protected
in my class? Or is there a way to declare protected in the public block in the class? What should be the correct way?