• 作用
    • 通过指针访问结构体中的成员
  • 利用操作符 -> 可以通过结构体指针访问结构体属性 ```cpp

    include

    include

using namespace std;

// 定义结构体 struct Student { string name; int age; int score; };

// 结构体指针 int main() { // 创建结构体变量 struct Student s = {“张三”, 18, 100}; // 通过指针指向结构体变量 struct Student *p = &s; // 通过指针访问结构体变量中的数据 利用 -> 访问 cout << “姓名” << p->name << endl; cout << “年龄” << p->age << endl; cout << “分数” << p->score << endl; return 0; } ```