We have two declare a point class with two Axis X and Y and we have to create/design its getter and setter functions.
As we know that a class has some data members and number functions. So, here we are going to declare two private data members X and Y of integer types. X will be used for the X-axis and Y will be used for the Y-axis.
Now, let's understand what are getter and setter member functions?
Setter functions are those functions which are used to set/assign the values to the variables (class's data members). Here, in the given class, the setter function is setPoint() - it will take the value of X and Y from the main() function and assign it to the private data members X and Y.
Getter functions are those functions which are used to get the values. Here, getX() and getY() are the getter function and they are returning the values of private members X and y respectively.
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer