POINT_OBJECT_COPY


POINT_OBJECT_COPY


* * *

START OF WEB PAGE COPY

* * *


POINT_OBJECT



image_link: https://github.com/karlinarayberinger/karlina_object_ultimate_starter_pack/blob/main/points_on_cartesian_grid.png


The C++ program featured in this tutorial web page implements a custom data type (i.e. class) named POINT. Each POINT type variable (i.e. POINT type object) represents exactly one Cartesian plane coordinate pair.

To view hidden text inside of the preformatted text boxes below, scroll horizontally.

class : object :: data_type : variable.

Each POINT object has an int type variable named X which represents a whole number position along the horizontal axis of the Cartesian plane.

Each POINT object has an int type variable named Y which represents a whole number position along the vertical axis of the Cartesian plane.


Software Application Files


C++ header file: https://github.com/karlinarayberinger/karlina_object_ultimate_starter_pack/blob/main/point.h

C++ source file: https://github.com/karlinarayberinger/karlina_object_ultimate_starter_pack/blob/main/point.cpp

C++ source file: https://github.com/karlinarayberinger/karlina_object_ultimate_starter_pack/blob/main/point_driver.cpp

plain-text file: https://github.com/karlinarayberinger/karlina_object_ultimate_starter_pack/blob/main/point_driver_output.txt


Program Compilation & Execution


STEP_0: Copy and paste each of the following C++ code files into a new text editor document and save each document as its respective file name:

point.h
point.cpp
point_driver.cpp

STEP_1: Open a Unix command line terminal application and set the current directory to wherever the C++ is located on the local machine (e.g. Desktop).

cd Desktop

STEP_2: Compile the C++ file into machine-executable instructions (i.e. object file) and then into an executable piece of software named app using the following command:

g++ point_driver.cpp point.cpp -o app

STEP_3: If the program compilation command does not work, then use the following command to install the C++ compiler:

sudo apt install build-essential

STEP_4: After running the g++ command, run the executable file using the following command:

./app

STEP_5: Observe program results on the command line terminal and in the output file.


POINT Class Declaration


C++ header file: https://github.com/karlinarayberinger/karlina_object_ultimate_starter_pack/blob/main/point.h

When copy-pasting the source code from the preformatted text box below into a text editor document, remove the spaces between the angle brackets and the library names in the preprocessing directives code block.


/**
 * file: point.h
 * type: C++ (header file)
 * author: Karlina Ray Beringer
 * date: 30_JULY_2022
 * license: PUBLIC_DOMAIN
 */

// If point.h has not already been linked to a source file (.cpp), then link this header file to the source file(s) which include this header file.
#ifndef POINT_H 
#define POINT_H

#include < iostream > // Include the library which defines command line input and output operations.
#include < fstream > // Include the library which defines file input and output operations.
#include < cmath > // Include the library which defines the square root function, trigonometric functions, and the floor function (i.e. the native C++ function which rounds a number down to its nearest integer).
#include < string > // Include the library which defines sequences of text characters as string type variables.

#define MINIMUM_X -999 // Define the constant MINIMUM_X to represent the value -999.
#define MINIMUM_Y -999 // Define the constant MINIMUM_Y to represent the value -999.
#define MAXIMUM_X 999 // Define the constant MAXIMUM_X to represent the value 999.
#define MAXIMUM_Y 999 // Define the constant MAXIMUM_X to represent the value 999.
#define PI 3.141592653589793238462643383279502884197169399 // Define the constant PI to represent the approximate value of a circle's circumference divided by that circle's diameter.

/**
 * Define a class which is used to instantiate POINT type software objects.
 * 
 * (object : class :: variable : data_type).
 * 
 * A POINT object is a specific data model of a two-dimensional point.
 * 
 * X stores one integer value at a time which is no smaller than MINIMUM_X and which is no larger than MAXIMUM_X.
 * Y stores one integer value at a time which is no smaller than MINIMUM_Y and which is no larger than MAXIMUM_Y.
 * 
 * X represents a specific whole number position along the x-axis (i.e. horizontal dimension) of a two-dimensional Cartesian grid.
 * Y represents a specific whole number position along the y-axis (i.e. vertical dimension) of the same two-dimensional Cartesian grid.
 */
class POINT
{
private:
    int X, Y; // data attributes
public:
    POINT(); // default constructor
    POINT(int X, int Y); // normal constructor
    POINT(const POINT & point); // copy constructor
    int get_X(); // getter method
    int get_Y(); // getter method
    bool set_X(int X); // setter method
    bool set_Y(int Y); // setter method
    double get_distance_from(POINT & point); // getter method
    double get_slope_of_line_to(POINT & point); // getter method
    void print(std::ostream & output = std::cout); // descriptor method
    friend std::ostream & operator << (std::ostream & output, POINT & point); // descriptor method
    ~POINT(); // destructor
};

// end of header file
#endif

POINT Class Definition


C++ source file: https://github.com/karlinarayberinger/karlina_object_ultimate_starter_pack/blob/main/point.cpp


/**
 * file: point.cpp
 * type: C++ (source file)
 * date: 31_JULY_2022
 * author: Karlina Ray Beringer
 * license: PUBLIC_DOMAIN 
 */

#include "point.h" // Include the C++ header file which contains preprocessing directives, variable declarations, and function prototypes for the POINT class.

/**
 * The default constructor method of the POINT class instantiates POINT type objects whose X value is set to 0 and whose Y value is set to 0.
 * 
 * The default constructor method of the POINT class is invoked when a POINT type variable is declared as follows:
 * 
 * // variable declaration one
 * POINT point_0; 
 * 
 * // variable declaration two
 * POINT point_1 = POINT();
 */
POINT::POINT()
{
    std::cout << "\n\nCreating the POINT type object whose memory address is " << this << "...";
    X = 0;
    Y = 0;
}

/**
 * The normal constructor method of the POINT class instantiates POINT type objects 
 * whose X value is set to the leftmost function input value (if that input value is in range) and 
 * whose Y value is set to the rightmost function input value (if that input value is in range).
 * 
 * If an input value is out of range, then set the corresponding int-type property of this to 0.
 * 
 * (The keyword this refers to the POINT object which is returned by this function).
 *
 * This normal constructor method of the POINT class is invoked when a POINT type variable is declared as follows:
 * 
 * // non-default POINT definition example one
 * POINT point_2 = POINT(-55,84);
 * 
 * // non-default POINT definition example two
 * POINT point_3 = POINT(3,-4);
 */
POINT::POINT(int X, int Y)
{
    std::cout << "\n\nCreating the POINT type object whose memory address is " << this << "...";
    this -> X = ((X < MINIMUM_X) || (X > MAXIMUM_X)) ? 0 : X; // Set the X property of the POINT instance being created to 0 if the function input X value is out of range.
    this -> Y = ((Y < MINIMUM_Y) || (Y > MAXIMUM_Y)) ? 0 : Y; // Set the Y property of the POINT instance being created to 0 if the function input Y value is out of range.
}

/**
 * The copy constructor method of the POINT class instantiates POINT type objects 
 * whose X value is set to the X value of the input POINT object 
 * and whose Y value is set to the Y value of the input POINT object.
 * 
 * (Note that the input POINT object named point is the predecessor to the object returned by this function).
 * 
 * (The keyword this refers to the POINT object which is returned by this function (i.e. the successor to point)).
 * 
 * The memory address of the predecessor POINT object is passed into the function as the variable named point.
 *
 * This copy constructor method of the POINT class is invoked when a POINT type variable is declared as follows:
 * 
 * // copy POINT definition example one
 * POINT point_4 = POINT(point_3);
 * 
 * // copy POINT definition example two
 * POINT point_5 = POINT(point_4);
 */
POINT::POINT(const POINT & point) 
{
    std::cout << "\n\nCreating the POINT type object whose memory address is " << this << "...";
    X = point.X;
    Y = point.Y;
}

/**
 * The getter method of the POINT class returns the value of the caller POINT object's X property.
 * 
 * X is an int type variable which stores exactly one integer value at a time which is no smaller than MINIMUM_X and which is no larger than MAXIMUM_X.
 */
int POINT::get_X()
{
    return X;
}

/**
 * The getter method of the POINT class returns the value of the caller POINT object's Y property.
 * 
 * Y is an int type variable which stores exactly one integer value at a time which is no smaller than MINIMUM_Y and which is no larger than MAXIMUM_Y.
 */
int POINT::get_Y()
{
    return Y;
}

/**
 * The setter method of the POINT class sets the POINT object's X property to the passed in value if that passed in value is in range.
 * 
 * If the input value is in range, then return true. Otherwise, do not change the caller POINT object's X value and return false.
 */
bool POINT::set_X(int X)
{
    if ((X >= MINIMUM_X) && (X <= MAXIMUM_X)) 
    {
        this -> X = X;
        return true;
    }
    return false;
}

/**
 * The setter method of the POINT class sets the POINT object's Y property to the passed in value if that passed in value is in range.
 * 
 * If the input value is in range, then return true. Otherwise, do not change the caller POINT object's Y value and return false.
 */
bool POINT::set_Y(int Y)
{
    if ((Y >= MINIMUM_Y) && (Y <= MAXIMUM_Y)) 
    {
        this -> Y = Y;
        return true;
    }
    return false;
}

/**
 * The getter method of the POINT class returns the nonzero length of the shortest path 
 * between the planar point represented by the the caller POINT object (i.e. this) 
 * and the planar point represented by the input POINT instance (i.e. point).
 * 
 * Use the Pythagorean Theorem to compute the length of a right triangle's hypotenuse 
 * (where the end points of that hypotenuse are represented by this and point).
 * 
 * A hypotenuse is the only side of a right triangle which does not form a right angle 
 * with any other side of that triangle.
 * 
 * A hypotenuse is the longest side of a triangle (and a triangle is a three-sided polygon 
 * in which three unique line segments connect three unique points).
 * 
 * // c is the length of a right triangle's hypotenuse.
 * // a is the length of that right triangle's horizontal side.
 * // b is the length of that triangle's vertical side.
 * (c * c) := (a * a) + (b * b). 
 * 
 * // sqrt is a native C++ function defined in the cmath library.
 * c := square_root( (a * a) + (b * b)). 
 */
double POINT::get_distance_from(POINT & point)
{
    int horizontal_difference = 0.0, vertical_difference = 0.0;
    horizontal_difference = X - point.X;
    vertical_difference = Y - point.Y;
    return sqrt((horizontal_difference * horizontal_difference) + (vertical_difference * vertical_difference));
}

/**
 * The getter method of the POINT class returns the slope of the line which intersects 
 * the planar point represented by the caller POINT instance (i.e. this)
 * and the planar point represented by the input POINT instance (i.e. point).
 * 
 * // y := f(x), 
 * // b := f(0), 
 * // f is a function whose input is an x-axis position and whose output is a y-axis position.
 * y := mx + b.
 * 
 * // m is a constant which represents the rate at which y changes as x changes.
 * // y is the output to linear function f. 
 * // b is a constant.
 * m := (y - b) / x. 
 * 
 * // m represents the difference of the y-values divided by the difference of the x-values
 * m := (point_1.y_coordinate - point_0.y_coordinate) / (point_1.x_coordinate - point_0.x_coordinate).
 */
double POINT::get_slope_of_line_to(POINT & point)
{
    double vertical_difference = 0.0, horizontal_difference = 0.0, result = 0.0;
    vertical_difference = point.Y - Y;
    horizontal_difference = point.X - X;
    result = vertical_difference / horizontal_difference;
    if (result == -0) result = 0; // Signed zeros sometimes occur inside of C++ program runtime instances.
    return result;
}

/**
 * The print method of the POINT class prints a description of the caller POINT object to the output stream.
 * 
 * Note that the default value of the function input parameter is the standard command line output stream (std::cout).
 * The default parameter is defined in the POINT class header file (i.e. point.h).
 */
void POINT::print(std::ostream & output)
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nthis := " << this << ". // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.";
    output << "\n&X = " << &X << ". // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.";
    output << "\n&Y = " << &Y << ". // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.";    
    output << "\nsizeof(int) = " << sizeof(int) << ". // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.";
    output << "\nsizeof(POINT) = " << sizeof(POINT) << ". // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.";
    output << "\nX := " << X << ". // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.";
    output << "\nY := " << Y << ". // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.";
    output << "\n--------------------------------------------------------------------------------------------------";
}

/**
 * The friend function is an alternative to the print method.
 * The friend function overloads the ostream operator (<<).
 * 
 * (Overloading an operator is assigning a different function to a native operator other than the function which that operator is used to represent by default).
 * 
 * Note that the default value of the leftmost function input parameter is the standard command line output stream (std::cout).
 * The default parameter is defined in the POINT class header file (i.e. point.h).
 * 
 * The friend function is not a member of the POINT class, but the friend function has access to the private and protected members 
 * of the POINT class and not just the public members of the POINT class.
 * 
 * The friend keyword only prefaces the function prototype for this function (which is declared in the header file named point.h). 
 * The friend keyword does not preface the definition for this function (which is defined immediately below this comment).
 */
std::ostream & operator << (std::ostream & output, POINT & point)
{
    point.print(output);
    return output;
}

/**
 * The destructor method of the POINT class de-allocates memory which was used to instantiate the POINT object which is calling this function.
 * 
 * The destructor method of the POINT class is implicitly invoked as soon as the program scope in which the caller POINT object was instantiated terminates.
 * In other words, no C++ command is needed to call this function. The destructor is called automatically by the event of the caller object's scope terminating.
 */
POINT::~POINT()
{
    std::cout << "\n\nDeleting the POINT type object whose memory address is " << this << "...";
}

Program Driver Source Code


C++ source file: https://github.com/karlinarayberinger/karlina_object_ultimate_starter_pack/blob/main/point_driver.cpp


/**
 * file: point_driver.cpp
 * type: C++ (source file)
 * date: 31_JULY_2022
 * author: Karlina Ray Beringer
 * license: PUBLIC_DOMAIN 
 */

#include "point.h" // Include the C++ header file which contains preprocessing directives, variable declarations, and function prototypes for the POINT class.

/** Declare function prototypes (function declarations and not function definitions) which pertain to program unit tests. */
void unit_test_0(std::ostream & output);
void unit_test_1(std::ostream & output);
void unit_test_2(std::ostream & output);
void unit_test_3(std::ostream & output);
void unit_test_4(std::ostream & output);
void unit_test_5(std::ostream & output);
void unit_test_6(std::ostream & output);
void unit_test_7(std::ostream & output);
void unit_test_8(std::ostream & output);
void unit_test_9(std::ostream & output);
void unit_test_10(std::ostream & output);
void unit_test_11(std::ostream & output);
void unit_test_12(std::ostream & output);

// Unit Test # 0: POINT class default constructor, POINT class print method, and POINT class destructor.
void unit_test_0(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 0: POINT class default constructor, POINT class print method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point;";
    output << "\npoint.print(output);";
    POINT point;
    point.print(output);
}

// Unit Test # 1: POINT class default constructor, POINT class print method (with default parameter), and POINT class destructor.
void unit_test_1(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 1: POINT class default constructor, POINT class print method (with default parameter), and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point;";
    output << "\npoint.print(); // Standard command line output (std::cout) is the default parameter for the POINT print method.";
    POINT point;
    point.print(); // Standard command line output (std::cout) is the default parameter for the POINT print method.
}

// Unit Test # 2: POINT class default constructor, POINT class overloaded ostream operator method (which is functionally the same as POINT class print method), and POINT class destructor.
void unit_test_2(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 2: POINT class default constructor, POINT class overloaded ostream operator method (which is functionally the same as POINT class print method), and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point;";
    output << "\noutput << point; // functionally equivalent to: point.print(output);";
    POINT point;
    output << point;
}

// Unit Test # 3: POINT class default constructor (using the function explicity rather than implicitly), POINT class overloaded ostream operator method, and POINT class destructor.
void unit_test_3(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 3: POINT class default constructor (using that function explicity rather than implicitly), POINT class overloaded ostream operator method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point = POINT(); // functionally equivalent to: POINT point;";
    output << "\noutput << point;";
    POINT point = POINT();
    output << point;
}

// Unit Test # 4: POINT class normal constructor (using only valid function inputs), POINT class overloaded ostream operator method, and POINT class destructor.
void unit_test_4(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 4: POINT class normal constructor (using only valid function inputs), POINT class overloaded ostream operator method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point = POINT(-503,404);";
    output << "\noutput << point;";
    POINT point = POINT(-503,404);
    output << point;
}

// Unit Test # 5: POINT class normal constructor (using only valid function inputs), POINT class overloaded ostream operator method, and POINT class destructor.
void unit_test_5(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 5: POINT class normal constructor (using only valid function inputs), POINT class overloaded ostream operator method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point_0 = POINT(-999,-999);";
    output << "\nPOINT point_1 = POINT(999, 999);";
    output << "\nPOINT point_2 = POINT(-999, 999);";
    output << "\nPOINT point_3 = POINT(999, -999);";
    output << "\noutput << point_0;";
    output << "\noutput << point_1;";
    output << "\noutput << point_2;";
    output << "\noutput << point_3;";
    POINT point_0 = POINT(-999,-999);
    POINT point_1 = POINT(999, 999);
    POINT point_2 = POINT(-999, 999);
    POINT point_3 = POINT(999, -999);
    output << point_0;
    output << point_1;
    output << point_2;
    output << point_3;
}

// Unit Test # 6: POINT class normal constructor (using both valid and invalid function inputs), POINT class overloaded ostream operator method, and POINT class destructor.
void unit_test_6(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 6: POINT class normal constructor (using both valid and invalid function inputs), POINT class overloaded ostream operator method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point_0 = POINT(-1000, -999);";
    output << "\nPOINT point_1 = POINT(999, 1000);";
    output << "\noutput << point_0;";
    output << "\noutput << point_1;";
    POINT point_0 = POINT(-1000, -999);
    POINT point_1 = POINT(999, 1000);
    output << point_0;
    output << point_1;
}

// Unit Test # 7: POINT class normal constructor, POINT class copy constructor, POINT class overloaded ostream operator method, and POINT class destructor.
void unit_test_7(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 7: POINT class normal constructor, POINT class copy constructor, POINT class overloaded ostream operator method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point_0 = POINT(333, -666);";
    output << "\nPOINT point_1 = POINT(point_0);";
    output << "\noutput << point_0;";
    output << "\noutput << point_1;";
    POINT point_0 = POINT(333, -666);
    POINT point_1 = POINT(point_0);
    output << point_0;
    output << point_1;
}

// Unit Test # 8: POINT class normal constructor, POINT class distance getter method, POINT class overloaded ostream operator method, and POINT class destructor.
void unit_test_8(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 8: POINT class normal constructor, POINT class distance getter method, POINT class overloaded ostream operator method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point_0 = POINT(1, 1);";
    output << "\nPOINT point_1 = POINT(-1, -1);";
    output << "\noutput << point_0;";
    output << "\noutput << point_1;";
    POINT point_0 = POINT(1, 1);
    POINT point_1 = POINT(-1, -1);
    output << point_0;
    output << point_1;
    output << "\npoint_0.get_distance_from(point_1) = " << point_0.get_distance_from(point_1) << ".";
    output << "\npoint_1.get_distance_from(point_0) = " << point_1.get_distance_from(point_0) << ".";
    output << "\npoint_0.get_distance_from(point_0) = " << point_0.get_distance_from(point_0) << ".";
    output << "\npoint_1.get_distance_from(point_1) = " << point_1.get_distance_from(point_1) << ".";
}

// Unit Test # 9: POINT class normal constructor, POINT class distance getter method, POINT class slope getter method, POINT class overloaded ostream operator method, and POINT class destructor.
void unit_test_9(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 9: POINT class normal constructor, POINT class distance getter method, POINT class slope getter method, POINT class overloaded ostream operator method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point_0 = POINT(0, 4);";
    output << "\nPOINT point_1 = POINT(3, 0);";
    output << "\nPOINT point_2 = POINT(0, 0);";
    output << "\noutput << point_0;";
    output << "\noutput << point_1;";
    output << "\noutput << point_2;";
    POINT point_0 = POINT(0, 4);
    POINT point_1 = POINT(3, 0);
    POINT point_2 = POINT(0, 0);
    output << point_0;
    output << point_1;
    output << "\npoint_0.get_distance_from(point_1) = " << point_0.get_distance_from(point_1) << ".";
    output << "\npoint_1.get_distance_from(point_2) = " << point_1.get_distance_from(point_2) << ".";
    output << "\npoint_2.get_distance_from(point_0) = " << point_2.get_distance_from(point_0) << ".";
    output << "\npoint_0.get_slope_of_line_to(point_1) = " << point_0.get_slope_of_line_to(point_1) << ".";
    output << "\npoint_1.get_slope_of_line_to(point_2) = " << point_1.get_slope_of_line_to(point_2) << ".";
    output << "\npoint_2.get_slope_of_line_to(point_0) = " << point_2.get_slope_of_line_to(point_0) << ".";
}

// Unit Test # 10: POINT class normal constructor, POINT class data attribute getter methods, POINT class overloaded ostream operator method, and POINT class destructor.
void unit_test_10(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 10: POINT class normal constructor, POINT class data attribute getter methods, POINT class overloaded ostream operator method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point = POINT(33.3, 88.8);";
    output << "\noutput << point;";
    POINT point = POINT(33.3, 88.8);
    output << point;
    output << "\npoint.get_X() = " << point.get_X() << ".";
    output << "\npoint.get_Y() = " << point.get_Y() << ".";
}

// Unit Test # 11: POINT class normal constructor, POINT class distance getter method, POINT class slope getter method, POINT class overloaded ostream operator method, and POINT class destructor.
void unit_test_11(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 11: POINT class normal constructor, POINT class distance getter method, POINT class slope getter method, POINT class overloaded ostream operator method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point = POINT(-1, 1);";
    output << "\noutput << point;";
    POINT point = POINT(-1, 1);
    output << point;
    output << "\npoint.get_distance_from(point) = " << point.get_distance_from(point) << ". // point refers to exactly one object";
    output << "\npoint.get_slope_of_line_to(point) = " << point.get_slope_of_line_to(point) << ". // point refers to exactly one object";
}

// Unit Test # 12: POINT class normal constructor, POINT class setter methods, POINT class overloaded ostream operator method, and POINT class destructor.
void unit_test_12(std::ostream & output) 
{
    output << "\n\n--------------------------------------------------------------------------------------------------";
    output << "\nUnit Test # 12: POINT class normal constructor, POINT class setter methods, POINT class overloaded ostream operator method, and POINT class destructor.";
    output << "\n--------------------------------------------------------------------------------------------------";
    output << "\nPOINT point = POINT(3, 3);";
    output << "\noutput << point;";
    POINT point = POINT(3, 3);
    output << point;
    output << "\nbool status = point.set_X(-1000);";
    output << "\noutput << std::endl << status << std::endl;";
    output << "\noutput << point;";
    bool status = point.set_X(-1000);
    output << std::endl << status << std::endl;
    output << point;
    output << "\nstatus = point.set_X(-999);";
    output << "\noutput << std::endl << status << std::endl;";
    output << "\noutput << point;";
    status = point.set_X(-999);
    output << std::endl << status << std::endl;
    output << point;
    output << "\nstatus = point.set_Y(-1000);";
    output << "\noutput << std::endl << status << std::endl;";
    output << "\noutput << point;";
    status = point.set_Y(-1000);
    output << std::endl << status << std::endl;
    output << point;
    output << "\nstatus = point.set_Y(-999);";
    output << "\noutput << std::endl << status << std::endl;";
    output << "\noutput << point;";
    status = point.set_Y(-999);
    output << std::endl << status << std::endl;
    output << point;
    output << "\nstatus = point.set_X(1000);";
    output << "\noutput << std::endl << status << std::endl;";
    output << "\noutput << point;";
    status = point.set_X(1000);
    output << std::endl << status << std::endl;
    output << point;
    output << "\nstatus = point.set_X(999);";
    output << "\noutput << std::endl << status << std::endl;";
    output << "\noutput << point;";
    status = point.set_X(999);
    output << std::endl << status << std::endl;
    output << point;
    output << "\nstatus = point.set_Y(1000);";
    output << "\noutput << std::endl << status << std::endl;";
    output << "\noutput << point;";
    status = point.set_Y(1000);
    output << std::endl << status << std::endl;
    output << point;
    output << "\nstatus = point.set_Y(999);";
    output << "\noutput << std::endl << status << std::endl;";
    output << "\noutput << point;";
    status = point.set_Y(999);
    output << std::endl << status << std::endl;
    output << point;
}

/** program entry point */
int main()
{
    // Declare a file output stream object.
    std::ofstream file;

    /**
     * Set the number of digits of floating point numbers which are printed to the command line to 50.
     * Set the number of digits of floating point numbers which are printed to the file output stream to 50.
     */
    std::cout.precision(50);
    file.precision(50);

    /**
     * If point_driver_output.txt does not already exist in the same directory as point_driver.cpp, 
     * then create a new file named point_driver_output.txt.
     * 
     * Then open the plain-text file named point_driver_output.txt 
     * and set that file to be overwritten with program data.
     */
    file.open("point_driver_output.txt");

    // Print an opening message to the command line terminal.
    std::cout << "\n\n--------------------------------";
    std::cout << "\nStart Of Program";
    std::cout << "\n--------------------------------";

    // Print an opening message to the file output stream.
    file << "--------------------------------";
    file << "\nStart Of Program";
    file << "\n--------------------------------";

    /** 
     * Run each one of the unit test functions for this program.
     * 
     * Call each unit test function twice such that the first function call prints text results to the command line terminal
     * and the second function call prints text results to the output file stream.
     */
    unit_test_0(std::cout);
    unit_test_0(file);
    unit_test_1(std::cout);
    unit_test_1(file);
    unit_test_2(std::cout);
    unit_test_2(file);
    unit_test_3(std::cout);
    unit_test_3(file);
    unit_test_4(std::cout);
    unit_test_4(file);
    unit_test_5(std::cout);
    unit_test_5(file);
    unit_test_6(std::cout);
    unit_test_6(file);
    unit_test_7(std::cout);
    unit_test_7(file);
    unit_test_8(std::cout);
    unit_test_8(file);
    unit_test_9(std::cout);
    unit_test_9(file);
    unit_test_10(std::cout);
    unit_test_10(file);
    unit_test_11(std::cout);
    unit_test_11(file);
    unit_test_12(std::cout);
    unit_test_12(file);

    // Print a closing message to the command line terminal.
    std::cout << "\n\n--------------------------------";
    std::cout << "\nEnd Of Program";
    std::cout << "\n--------------------------------\n\n";

    // Print a closing message to the file output stream.
    file << "\n\n--------------------------------";
    file << "\nEnd Of Program";
    file << "\n--------------------------------";

    // Close the file output stream.
    file.close();

    // Exit the program.
    return 0;
}

Sample Program Output


plain-text file: https://github.com/karlinarayberinger/karlina_object_ultimate_starter_pack/blob/main/point_driver_output.txt


--------------------------------
Start Of Program
--------------------------------

--------------------------------------------------------------------------------------------------
Unit Test # 0: POINT class default constructor, POINT class print method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point;
point.print(output);

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 0. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 0. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
Unit Test # 1: POINT class default constructor, POINT class print method (with default parameter), and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point;
point.print(); // Standard command line output (std::cout) is the default parameter for the POINT print method.

--------------------------------------------------------------------------------------------------
Unit Test # 2: POINT class default constructor, POINT class overloaded ostream operator method (which is functionally the same as POINT class print method), and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point;
output << point; // functionally equivalent to: point.print(output);

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 0. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 0. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
Unit Test # 3: POINT class default constructor (using that function explicity rather than implicitly), POINT class overloaded ostream operator method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point = POINT(); // functionally equivalent to: POINT point;
output << point;

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 0. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 0. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
Unit Test # 4: POINT class normal constructor (using only valid function inputs), POINT class overloaded ostream operator method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point = POINT(-503,404);
output << point;

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := -503. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 404. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
Unit Test # 5: POINT class normal constructor (using only valid function inputs), POINT class overloaded ostream operator method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point_0 = POINT(-999,-999);
POINT point_1 = POINT(999, 999);
POINT point_2 = POINT(-999, 999);
POINT point_3 = POINT(999, -999);
output << point_0;
output << point_1;
output << point_2;
output << point_3;

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e818. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e818. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e81c. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := -999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := -999. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e820. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e820. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e824. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 999. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e828. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e828. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e82c. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := -999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 999. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := -999. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
Unit Test # 6: POINT class normal constructor (using both valid and invalid function inputs), POINT class overloaded ostream operator method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point_0 = POINT(-1000, -999);
POINT point_1 = POINT(999, 1000);
output << point_0;
output << point_1;

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e828. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e828. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e82c. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 0. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := -999. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 0. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
Unit Test # 7: POINT class normal constructor, POINT class copy constructor, POINT class overloaded ostream operator method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point_0 = POINT(333, -666);
POINT point_1 = POINT(point_0);
output << point_0;
output << point_1;

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e828. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e828. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e82c. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 333. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := -666. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 333. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := -666. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
Unit Test # 8: POINT class normal constructor, POINT class distance getter method, POINT class overloaded ostream operator method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point_0 = POINT(1, 1);
POINT point_1 = POINT(-1, -1);
output << point_0;
output << point_1;

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e828. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e828. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e82c. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 1. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 1. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := -1. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := -1. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
point_0.get_distance_from(point_1) = 2.8284271247461902909492437174776569008827209472656.
point_1.get_distance_from(point_0) = 2.8284271247461902909492437174776569008827209472656.
point_0.get_distance_from(point_0) = 0.
point_1.get_distance_from(point_1) = 0.

--------------------------------------------------------------------------------------------------
Unit Test # 9: POINT class normal constructor, POINT class distance getter method, POINT class slope getter method, POINT class overloaded ostream operator method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point_0 = POINT(0, 4);
POINT point_1 = POINT(3, 0);
POINT point_2 = POINT(0, 0);
output << point_0;
output << point_1;
output << point_2;

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e820. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e820. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e824. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 0. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 4. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e828. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e828. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e82c. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 3. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 0. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
point_0.get_distance_from(point_1) = 5.
point_1.get_distance_from(point_2) = 3.
point_2.get_distance_from(point_0) = 4.
point_0.get_slope_of_line_to(point_1) = -1.3333333333333332593184650249895639717578887939453.
point_1.get_slope_of_line_to(point_2) = 0.
point_2.get_slope_of_line_to(point_0) = inf.

--------------------------------------------------------------------------------------------------
Unit Test # 10: POINT class normal constructor, POINT class data attribute getter methods, POINT class overloaded ostream operator method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point = POINT(33.3, 88.8);
output << point;

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 33. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 88. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
point.get_X() = 33.
point.get_Y() = 88.

--------------------------------------------------------------------------------------------------
Unit Test # 11: POINT class normal constructor, POINT class distance getter method, POINT class slope getter method, POINT class overloaded ostream operator method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point = POINT(-1, 1);
output << point;

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := -1. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 1. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
point.get_distance_from(point) = 0. // point refers to exactly one object
point.get_slope_of_line_to(point) = -nan. // point refers to exactly one object

--------------------------------------------------------------------------------------------------
Unit Test # 12: POINT class normal constructor, POINT class setter methods, POINT class overloaded ostream operator method, and POINT class destructor.
--------------------------------------------------------------------------------------------------
POINT point = POINT(3, 3);
output << point;

--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 3. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 3. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
bool status = point.set_X(-1000);
output << std::endl << status << std::endl;
output << point;
0


--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 3. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 3. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
status = point.set_X(-999);
output << std::endl << status << std::endl;
output << point;
1


--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := -999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 3. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
status = point.set_Y(-1000);
output << std::endl << status << std::endl;
output << point;
0


--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := -999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 3. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
status = point.set_Y(-999);
output << std::endl << status << std::endl;
output << point;
1


--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := -999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := -999. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
status = point.set_X(1000);
output << std::endl << status << std::endl;
output << point;
0


--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := -999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := -999. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
status = point.set_X(999);
output << std::endl << status << std::endl;
output << point;
1


--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := -999. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
status = point.set_Y(1000);
output << std::endl << status << std::endl;
output << point;
0


--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := -999. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------
status = point.set_Y(999);
output << std::endl << status << std::endl;
output << point;
1


--------------------------------------------------------------------------------------------------
this := 0x7ffea033e830. // The keyword named this is a pointer to the memory address of the first cell of a POINT-sized block of memory cells which are allocated to the instantiation of some POINT-type object.
&X = 0x7ffea033e830. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named X.
&Y = 0x7ffea033e834. // The operation returns the memory address of the first memory cell of an int-sized block of memory cells which are allocated to the instantiation of some int-type variable named Y.
sizeof(int) = 4. // The operation returns the number of bytes of memory which an int-type variable occupies. Each memory cell has a data capacity of 1 byte.
sizeof(POINT) = 8. // The operation returns the number of bytes of memory which a POINT-type object occupies. Each memory cell has a data capacity of 1 byte.
X := 999. // X stores an int-type value which represents the horizontal position of a two-dimensional point plotted on a Cartesian grid.
Y := 999. // Y stores an int-type value which represents the vertical position of a two-dimensional point plotted on a Cartesian grid.
--------------------------------------------------------------------------------------------------

--------------------------------
End Of Program
--------------------------------

This page was last updated on 31_JULY_2022. The content displayed on this page is licensed as PUBLIC_DOMAIN intellectual property.


* * *

END OF WEB PAGE COPY

* * *


This web page was last updated on 09_SEPTEMBER_2022. The content displayed on this web page is licensed as PUBLIC_DOMAIN intellectual property.