#include <iostream>
#include <vector>

using namespace std;

class Square {

    private:
        int side {1};

    public:
        Square() = default;
        Square(int s) : side{s} {};
        int getSide() {
            return side;
        }
        int calcArea() {
            return side * side;
        }

};

int main() {

    int x {25}; // int variable
    int *pX; // pointer

    pX = &x;

    cout << "The value of x is " << x << endl;
    cout << "The memory address of x is " << pX << endl;

    cout << "The value of x is " << *pX << endl;

    // Comparing two pointers
    int *pX2 {pX};
    if (pX == pX2) {
        cout << "TRUE!" << endl;
    }
    if (*pX == *pX2) {
        cout << "TRUE!" << endl;
    }

    // Pointer initialization
    int y {1}, *pY {&y};

    cout << "The value of y is " << y << endl;
    cout << "The memory address of y is " << pY << endl;

    // Ititialize as null pointer
    int *pInt {nullptr};
    if (pInt != nullptr) {
        cout << "TRUE!" << endl;
    } else {
        cout << "FALSE!" << endl;
    }
    if (pInt) {
        cout << "TRUE!" << endl;
    } else {
        cout << "FALSE!" << endl;
    }

    // Pointer to structs or classes
    Square sq {99};
    Square *pSq = &sq;

    // Accessing object members through a pointer
    cout << (*pSq).getSide() << endl;

    // Structure point operator ->
    cout << pSq->getSide() << endl;

    return 0;

}