0
我儘量讓PIMPL模式:不能使PIMPL
//header
#include <memory>
class Table
{
public:
Table();
private:
class Impl;
std::unique_ptr<Impl> *m_impl;
};
//source
#include <vector>
#include "table.hpp"
struct Table::Impl {
Impl();
};
Table::Table()
: m_impl { std::make_unique<Impl>() }
{
}
但我得到一個錯誤:
table.cpp:9: error: cannot convert 'brace-enclosed initializer list' to 'std::unique_ptr*' in initialization : m_impl { std::make_unique() }
我不明白,我做錯了,如何解決它。
謝謝!這是一個愚蠢的錯誤,只是我只學習C++。 –