->在C++中是什么意思?

来源:互联网 发布:多功能数据采集系统 编辑:程序博客网 时间:2024/06/09 20:56

-> 在c++中为取成员运算符

对象指针/结构指针->成员变量/成员函数

该运算符的作用,取得指针所指向的类对象或结构变量的成员变量的值,或者调用其成员函数。

例如:

int *p;
struct student
{  char name[20];
   int num;
}stu;
stu={xiaoming,90};
p=&stu;
cout<<stu.name<<stu.num<<endl;
cout<<p->name<<p->num<<endl;
这两个cout的效果是一样的