Array of Pointers

Create an array of Person pointers; Use the following Person struct definition:

struct Person {
    string name;
    int age;
};

Allocate an array of size 3 and have each element of the array point to a unique instance of a Person struct. Then use the array of pointers to print the instances of Person.

Sample Output:

Oscar, 21
Tommy, 20
Vegeta, 9001


Improve this page