Initialization of reference member requires a temporary variable C++

后端 未结 12 1899
自闭症患者
自闭症患者 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:28

    Keep in mind that once a reference is initialized to point to something, you cannot alter it to point to something else. If this is not the desired behavior, then you should use a pointer or a copy of the object instead.

提交回复
热议问题