該類容摘抄自以下鏈接,為學習之后的記錄,不是鄙人原創。
學習鏈接:https://blog.csdn.net/a2013126370/article/details/78230890
typedef struct
{
...
...
}POINT,*POINT_P;
POINT為結構名,這個名字主要是為了在結構體中包含自己為成員變量的時候有用
POINT_T為struct POINT的別名
POINT_P為struct POINT*的別名
POINT為結構體名,可聲明對象;
POINT_P為struct POINT*的別名,等同於typedef POINT * POINT_P;
* 結構體指針如何使用(二層指針)
#include <iostream>
using namespace std;
typedef struct {
int x;
int y;
}point,*_point; //定義類,給類一個別名
//驗證 typedef point * _point;
int main()
{
_point *hp;
point pt1;
pt1.x = 2;
pt1.y = 5;
_point p;
p = &pt1;
hp = &p;
cout<< pt1.x<<" "<<pt1.y <<endl;
cout<< (**hp).x <<" "<< (**hp).y <<endl;
return 0;
}
//運行結果:2 5
2 5