pointer vs non-pointer members of a class

前端 未结 5 1065
深忆病人
深忆病人 2021-02-02 02:26

My questions is, suppose we have two classes A and B. I want to have an object of B in class A.

Should I use,

class A
{
  public:
          A();
                 


        
5条回答
  •  伪装坚强ぢ
    2021-02-02 02:39

    Use the second, try to avoid using new as much as possible in C++ unless you are using RAII.

提交回复
热议问题