一般的项目中,如果要获取调用者参数的地址可以考虑使用二级指针。
程序运行截图如下:

源码如下:
#include <iostream>
#include <conio.h>
using namespace std;
class A {
public:
void print() {
cout << "Class A print called!n";
}
};
void analyseParameter(A **a) {
cout << "The &a is " << &a << endl;
cout << "The a is " << a << endl;
cout << "The *a is " << *a << endl;
}
void main() {
A *myA = new A;
myA->print();
cout << "The myA address is " << &myA << endl;
analyseParameter(&myA);
_getch();
}
可以发现,直接把&myA传过去,用二级指针接收,就完事了!!!!!!!!
感觉这方法有点歪门邪道!!!!
最后
以上就是如意往事最近收集整理的关于C++工作笔记-对二级指针的进一步理解(获取调用者的地址)的全部内容,更多相关C++工作笔记-对二级指针内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复