I am a student learning, I was tasked with the following;

Create a class called AddressBook. Create the address book with a dynamic array and when the object is created, the programmer should specify the maximum number of items in the addressbook. (e.g.) AddressBook myAddressBook(20); It should contain a method called addName that will take a name and phone number and add it to the address book. There should be a method called findName that will take a string for the name and return the phone number if found in the list otherwise return “Person Not Found”. The class should have a method called display to show all the entries in the address book sorted by last name (last name, first name). Create a main function to test your class. Inside the main ask for five names and enter them into the address book. In the main, look for one that is in the address book and test for a name that is not in the address book. Finally, in the main, display the names in alphabetical order from the address book. You should have the sort inside the class AddressBook.

I have created the program but having trouble compiling for multiple reasons. Here is my code. I am having a bit of trouble on how to use classes and the pointers. I appreciate any help given. I get these errors;

In function 'int main()':
33:32: error: 'name' was not declared in this scope
36:32: error: 'phone' was not declared in this scope
42:31: error: 'name' was not declared in this scope
42:37: error: 'phone' was not declared in this scope
At global scope:
53:39: error: return type specification for constructor invalid
In function 'void addName(std::string, int)':
61:16: error: aggregate 'addName(std::string, int)::Person p' has incomplete type and cannot be defined
64:2: error: 'arr' was not declared in this scope
64:6: error: 'count' was not declared in this scope
In function 'void sort()':
69:10: error: 'count' was not declared in this scope
75:8: error: 'arr' was not declared in this scope
77:19: error: variable 'sort()::Person temp' has initializer but incomplete type
In member function 'void AddressBook::Display()':
90:15: error: 'i' was not declared in this scope

I have been trying to fix them to no avail, and this is due in a few hours. Here is my code, any and all help will be appreciated!

#include <iostream>
#include <string>
using namespace std;

class AddressBook
{
private:
    struct Person
    {
        string name;
        int phone;
    };
    struct Person* arr;
    int count;

public:
    AddressBook(int size);
    void addName(string name, int phone);
    void sort();
    void Display();
    void findName(string name);
};

int main()
{
    AddressBook myAddressBook(20);

    for (int i = 0; i < 5; i++)
    {
        cout << "Enter name, (Lastname Firstname): ";
        cin >> myAddressBook.addName(name) << endl;

        cout << "Enter phone number: ";
        cin >> myAddressBook.addName(phone) << endl;

        myAddressBook.addName(name, phone);
    }

    cout << "Enter a name to find it's phone number: ";
    cin >> myAddressBook.addName(name, phone);
    cout << myAddressBook.findName(name) << endl;

    cout << "Enter a name that is NOT in the addressbook: ";
    cin >> myAddressBook.addName(name, phone);
    cout << myAddressBook.findName(name) << endl;

    myAddressBook.Display();
    return 0;
}

void AddressBook::AddressBook(int size)
{
    count = 0;
    arr = new Person[size];
}

void addName(string name, int phone)
{
    struct Person p;
    p.name = name;
    p.phone = phone;
    arr[count++] = p;
}

void sort()
{
    int n = count;

    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = 0; j < i; j++)
        {
            if (arr[j].lastName > arr[j + 1].lastName)
            {
                struct Person temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }
}

void AddressBook::Display()
{
    sort();
    for (int i = 0; i < count; i++);
    {
        cout << arr[i].lastName << "," << arr[i].firstName << " : " << arr[i].phoneNumber << endl;
    }
}

void AddressBook::findName(string name)
{
    int i;
    for (i = 0; i < count; i++)
    {
        if (arr[i].name == name)
            break;
    }

    if (i == count)
    {
        cout << "Person not found! Try again please." << endl;
        return;
    }

    cout << "Phone Number : " << arr[i].phone << endl;
}