Unique_ptr and forward declaration

后端 未结 2 941
礼貌的吻别
礼貌的吻别 2020-11-30 11:28

Say I have two classes:

\"Foo.h\"

#pragma once    
class Foo
{
public:
    Foo()
    {

    };

    ~Foo()
    {

    };
};

\"A.h\"

2条回答
  •  自闭症患者
    2020-11-30 12:08

    It is no possible for 'A' to not have a constructor.

    If you comment the constructor you wrote, the compiler will make a default constructor for you and it won't necessarily be in the same place you defined the one you made. Causing said problem.

提交回复
热议问题