开发者社区 问答 正文

PointList &L 与 PointList L 的区别?

最近看老师的程序
PointList 就是一个点列表结构体

struct Point
{
    float x, y;
};

struct PointList
{
    int size;
    int cur;
    struct Point points[10];
};

为什么有时候在函数中使用 PointList L 做参数,有时候使用 PointList &L,两者有什么区别呢?

展开
收起
a123456678 2016-03-09 16:11:00 2491 分享 版权
1 条回答
写回答
取消 提交回答
  • PointList L传值,PointList &L传址。

    对于非基元类型,请一律使用PointList &L作为形参,如果不想改动实参,请用const PointList &L。

    2019-07-17 18:56:22
    赞同 展开评论
问答地址: