博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++ arrow operator ,, –> Operator,,,指针专属
阅读量:6364 次
发布时间:2019-06-23

本文共 841 字,大约阅读时间需要 2 分钟。

C++ has an operator that can be used with a pointer to simplify the notation for

specifying the members of a struct or a class. The arrow operator , -> , combines
the actions of a dereferencing operator, * , and a dot operator to specify a member of
a dynamic struct or class object that is pointed to by a given pointer. For example,
suppose you have the following definition:
struct Record
{
int number;
char grade;
};
The following creates a dynamically allocated variable of type Record and sets the
member variables of the dynamic struct variable to 2001 and 'A' .
Record *p;
p = new Record;
p->number = 2001;
p->grade = 'A';
The notations
p->grade
and
(*p).grade
have the same meaning. However, the first is more convenient and is almost always the
notation used.

转载于:https://www.cnblogs.com/gisbeginner/archive/2012/10/30/2746328.html

你可能感兴趣的文章
简单易用的APP制作软件,KM盒子V6.3版发布
查看>>
Appium移动自动化测试之问题总结
查看>>
UIScrollView 大概是如何实现的,它是如何捕捉、响应手势的?
查看>>
wx-cli:简易微信小程序开发脚手架
查看>>
asp.net MVC中实现调取web api
查看>>
keepalived实现服务高可用
查看>>
iOS模型以及使用
查看>>
NSString 去除空格
查看>>
swift - 网络请求数据处理 - 协议处理
查看>>
[BZOJ1588]营业额统计(Splay)
查看>>
[BZOJ 4869][SHOI&SXOI2017]相逢是问候(扩展欧拉定理+线段树)
查看>>
2017-08-13
查看>>
条件语句优化面面观
查看>>
集成友盟微信登录没有回调
查看>>
在CentOS Linux系统上,添加新的端口,启用ssh服务
查看>>
dbcp数据库连接池简单使用
查看>>
leetcode-38-Count and Say
查看>>
从零开始写一个node爬虫(上)—— 数据采集篇
查看>>
java调用远程服务器shell脚本
查看>>
Python监听鼠标键盘事件
查看>>