Initialization of reference member requires a temporary variable C++

后端 未结 12 1883
自闭症患者
自闭症患者 2020-12-10 03:29
struct Div
{
   int i;
   int j;
};   

class A
{
    public:
             A();
             Div& divs;
};

In my constructor definition, I have

12条回答
  •  情歌与酒
    2020-12-10 04:27

    In "English": a reference refers to something. It cannot refer to nothing (null). That's why references are safer to use then pointers.

提交回复
热议问题