Pointers to classes (From the note of my firend)
Pointers to classes
Objects can also be pointed to by pointers: Once declared, a class becomes a valid type, so it can be used as the type pointed to by a pointer. For example:
|
|
is a pointer to an object of class Rectangle.
Similarly as with plain data structures, the members of an object can be accessed directly from a pointer by using the arrow operator (->). Here is an example with some possible combinations:
|
|
|
This example makes use of several operators to operate on objects and pointers (operators
*, &, ., ->, []). They can be interpreted as:
| expression | can be read as |
|---|---|
*x |
pointed to by x |
&x |
address of x |
x.y |
member y of object x |
x->y |
member y of object pointed to by x |
(*x).y |
member y of object pointed to by x (equivalent to the previous one) |
x[0] |
first object pointed to by x |
x[1] |
second object pointed to by x |
x[n] |
(n+1)th object pointed to by x |
Most of these expressions have been introduced in earlier chapters. Most notably, the chapter about arrays introduced the offset operator ([]) and the chapter about plain data structures introduced the arrow operator (->).
版权声明:本文博客原创文章,博客,未经同意,不得转载。
Pointers to classes (From the note of my firend)的更多相关文章
- Leetcode 笔记 116 - Populating Next Right Pointers in Each Node
题目链接:Populating Next Right Pointers in Each Node | LeetCode OJ Given a binary tree struct TreeLinkNo ...
- LEETCODE —— Populating Next Right Pointers in Each Node
Populating Next Right Pointers in Each Node Given a binary tree struct TreeLinkNode { TreeLinkNode * ...
- LeetCode OJ 116. Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *nex ...
- LeetCode - Populating Next Right Pointers in Each Node
题目: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode ...
- 【leetcode】Populating Next Right Pointers in Each Node
Populating Next Right Pointers in Each Node Given a binary tree struct TreeLinkNode { TreeLinkNode * ...
- 【leetcode】Populating Next Right Pointers in Each Node I & II(middle)
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *nex ...
- [LeetCode]题解(python):116 Populating Next Right Pointers in Each Node
题目来源 https://leetcode.com/problems/populating-next-right-pointers-in-each-node/ Given a binary tree ...
- 29. Populating Next Right Pointers in Each Node && Populating Next Right Pointers in Each Node II
Populating Next Right Pointers in Each Node OJ: https://oj.leetcode.com/problems/populating-next-rig ...
- Populating Next Right Pointers in Each Node II--leetcode难题讲解系列
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *nex ...
随机推荐
- winform正在使用dsoframer迅速"Unable to display the inactive document.Click here to reacitive the document."
于winform正在使用dsoframer 1.3加载word档,但在axFramerControl1.Open("NPOI.docx");于axFramerControl1控制显 ...
- Servlet上传文件
Servlet上传文件 1.准备工作 (1)利用FileUpload组件上传文件,须要到apache上下载commons-fileupload-1.3.1.jar 下载地址:http://common ...
- MTK MOTA升级步骤
MOTA的前提下有其自己的server,MTK我在已经完成,可以MTK应用,然后移动到它自己的server向上. 1.打开ProjectConfig.mk中间MTK_SYSTEM_UPDATE_SUP ...
- RH253读书笔记(9)-Lab 9 Account Management Methods
Lab 9 Account Management Methods Goal: To build skills with PAM configuration Sequence 1: Track Fail ...
- VS公布 错 到文件失败 复制到
他自己和构建网站 ASP.MVC4 最近更改写功能 自此从未公布 已经报道 错 15 到文件失败 easyui\themes\gray\images\Thumbs.db 拷贝到 obj\Releas ...
- hdu4570Multi-bit Trie (间隙DP)
Problem Description IP lookup is one of the key functions of routers for packets forwarding and clas ...
- DOM笔记2
<!-- 节点类型检查 if(someNode.nodeType==ElementNode){ alert("Node is an element"); } 或者 if(so ...
- 初探boost之progress_display库学习笔记
progress_display 用途 progress_display能够在控制台上显示程序的运行进度,假设程序运行非常耗费时间,那么它能提供一个友好的用户界 面,不至于让用户在等待中失去耐心,甚至 ...
- paip.自适应网页设计 同 响应 与设计的原理的差and实践总结
paip.自适应网页设计 同 响应 与设计的原理的差and实践总结 响应式Web设计(Responsive Web design)的理念是: 1 #-----------自适应布局VS响应式布局 2 ...
- Spring AOP在pointcut expression解析表达式 并匹配多个条件
Pointcut 方法是那些需要运行"AOP",由"Pointcut Expression"为了描述叙事. Pointcut以下方法可以通过定义任&&a ...