C++ Pointers to Structure

#include <iostream>
using namespace std;

// Define a structure named 'Person' with two members: 'name' and 'age'
struct Person {
    string name;
    int age;
};

int main() {
    // Declare a variable 'person1' of type 'Person'
    Person person1;

    // Declare a pointer to 'Person' named 'ptrPerson' and assign the address of 'person1' to it
    Person *ptrPerson = &person1;

    // Access the 'name' member of 'person1' using the pointer 'ptrPerson' and assign a value
    ptrPerson->name = "John";

    // Access the 'age' member of 'person1' using the pointer 'ptrPerson' and assign a value
    ptrPerson->age = 25;

    // Display the values stored in 'person1' using the pointer 'ptrPerson'
    cout << "Person Name: " << ptrPerson->name << endl;
    cout << "Person Age: " << ptrPerson->age << endl;

    return 0;
}