#include <QCoreApplication>
#include <QtCore>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
//栈上的指针
int* p1 = new int(1);
qDebug() << *p1;
//堆上的指针
int** p2;
p2 = new int*;
*p2 = new int(2);
qDebug() << **p2;
//栈上的引用
int x = 3;
int& r1 = x;
qDebug() << r1;
//堆上的引用
int* p3 = new int(4);
int& r2 = *p3;
qDebug() << r2;
return a.exec();
}
//栈指针,指向栈对象
int x = 1;
int* p1 = &x;
qDebug() << *p1;
//栈指针,指向堆对象
int* p2 = new int(2);
qDebug() << *p2;
//堆指针,指向栈对象
int y = 3;
int** p3 = new int*;
*p3 = &y;
qDebug() << **p3;
//堆指针,指向堆对象
int** p4 = new int*;
*p4 = new int(4);
qDebug() << **p4;