While I have never seen this pattern in practice, you could separate implementation and interface (though it is normally the other way around)
namespace detail {
class Impl {
protected:
Impl() : x_(0) {}
int x_;
void internal() { x_ = 1; }
void something_else() { x_ = 2; }
};
}
class Interface : public detail::Impl {
public:
int x() const { return x_; }
void x(int x) { x_ = x; }
};
Or a step further without derivation:
class Interface;
namespace detail {
class Impl {
private:
friend class ::Interface;
Impl() : x_(0) {}
int x_;
void internal() { x_ = 1; }
void something_else() { x_ = 2; }
};
}
class Interface {
public:
int x() const { return impl_.x_; }
void x(int x) { impl_.x_ = x; }
private:
Impl impl_;
};
Also lookup the PIMPL idiom, which is often used to reduce header/library/client coupling and to increase compile times.