Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
struct Person {
    string name;      // position 0
    int age;         // position 1
    string address;  // position 2
}

Person p = {"Alice Smith", 25, "123 Main Street"};

// While p.name and p.address are preferred, you can use indexing:
string name = p[0];    // returns: "Alice Smith"
string addr = p[2];    // returns: "123 Main Street"

// Multiple values can be accessed:
return p[1], p[2];   // returns: 25, "123 Main Street"See also

...

Learn more