结构体指针
1 #include <iostream> 2 using namespace std; 3 struct Student 4 { 5 string name; 6 int age; 7 int score; 8 }; 9 int main() { 10 Student s = {"张三",18,100}; 11 Student *p= &s; 12 cout<<"姓名:"<<p->name<<endl; 13 cout<<"年龄:"<<p->age<<endl; 14 cout<<"分数:"<<p->score<<endl; 15 return 0; 16 }

浙公网安备 33010602011771号