C++基础__结构体指针
还是以矩形为例
struct Rectangle
{
int length;
int breadth'
};
结构体指针的访问
int main()
{
Rectangle r = {10 ,5};
Rectangle * p = &r;
r.length = 15;
(*p).length = 20'
p->length = 10;
}
动态创建实例
int main()
{
Rectangle *p;
p =(Rectangle *)malloc(sizeof(Rectangle));
p->length = 10;
p->breadth = 5;
}

浙公网安备 33010602011771号