#include <iostream>
using namespace std;
typedef struct _st_point
{
int x;
int y;
}st_point,*p_st;
int main()
{
p_st p;
p=new st_point;
int x=p->x=0;
cout << x << endl;
delete p;
return 0;
}
本文通过一个C++程序示例,展示了如何定义和使用结构体指针,包括分配内存、访问成员变量以及释放内存的过程。对于理解C++中结构体与指针的基本用法很有帮助。
#include <iostream>
using namespace std;
typedef struct _st_point
{
int x;
int y;
}st_point,*p_st;
int main()
{
p_st p;
p=new st_point;
int x=p->x=0;
cout << x << endl;
delete p;
return 0;
}
1101
354
1041

被折叠的 条评论
为什么被折叠?