2016-08-18 3 views
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() }

합니다.

답변

4

m_implunique_ptr에 대한 포인터입니다.

std::unique_ptr<Impl> m_impl; 
+0

로 변경

std::unique_ptr<Impl> *m_impl; 

감사합니다! 그것은 바보 같은 오류입니다. C++만을 연구합니다. –

관련 문제