c++ - 获取指向指针的指针元素(c++)
问题描述
这是我写的代码:
#include <iostream>
using namespace std;
struct working{
int*pointer;
int inf;
};
int main()
{
working one;
working *two;
working **three;
one.inf=5;
one.pointer=NULL;
two=&one;
cout<<two<<endl;
cout<<two->pointer<<endl;
cout<<two->inf<<endl;
three=&two;
cout<<three<<endl;
cout<<three->pointer<<endl;
return 0;
}
如何以与我所做的类似的方式获取inf
orpointer
元素?如果可能的话,你能告诉我做什么。如果我用它切换它为什么不能编译?three
two
*three=two
three=&two
解决方案
three = &two;
cout << (*three) << endl;
cout << (*three)->pointer << endl;
推荐阅读
- wordpress - cURL 错误 18:传输已关闭,剩余 116 个字节要读取 - wordpress
- if-statement - Sumproduct & 数组公式
- javascript - 动态获取所有素材图标列表
- avplayer - AVPlayer 全屏崩溃
- c - 如何在头文件中声明结构并在另一个 .h 文件中对其进行初始化?
- google-dfp - 使用过滤器 DFP 广告单元(顶级)保存的查询,但与 DFP API 不兼容
- angularjs - $injector:modulerr 是什么意思?
- c - 函数可以返回一个在其中初始化的值吗?
- r - 在 JAGS 中,随机节点是如何工作的?
- google-chrome-extension - background.js 仅在 Chrome 扩展中打开 DevTools 时有效