---
# System prepended metadata

title: forward declaration + unique_ptr

---

forward declaration + unique_ptr
==

```cpp
// MainClass.h
struct MyClassImp;
struct MyClassImpDeleter{ void operator()(MyClassImp*); }

class MyClass
{
    std::unique_ptr<MyClassImp, MyClassImpDeleter> pImp;    
};

```


```cpp
// MainClass.cpp 
struct MyClassImp {
    ...
};

void MyClassImpDeleter::operator()(MyClassImp* pImp) { delete pImp; }

```


References:
- [StackOverflow.com/std::unique_ptr with an incomplete type won't compile](https://stackoverflow.com/a/17950450/2210478)