Using PIMPL but single header + multiple cpp files

69 Views Asked by At

I have a header file class.hpp that contains my main object

class Class {
public:
  Class();
  ~Class();
private:
  struct Impl;
  std::unique_ptr<Impl> impl;

};

I then have my main implementation class_impl.cpp

#include "Class.hpp"

struct Class::Impl {
  int x;

};

Class::Class() : impl(new Impl)
{

}

I now want to have another class_impl_extended.cpp because class_impl.cpp is getting very long.

I tried to do this and access impl but this fails to compile with:

error: invalid use of incomplete type 'struct Class::Impl'
0

There are 0 best solutions below