// ctest.cpp : Defines the entry point for the console application.

#include "c.h"

int main()
{
  C aC("aC");
  return 0;
}

// c.h - The interface definition

#include <memory>
#include <string>

class CImpl; // forward declaration to incomplete type

class C
{
  std::auto_ptr<CImpl> p_; // auto_ptr to incomplete type
  std::string s;

  C(C const &);              // not implemented
  C& operator = (C const &); // not implemented
public:
  C(const std::string& s_);
  ~C();                      // explicitly declare destructor
};

// cimpl.h

#include <string>

class CImpl {
  std::string s;
public:
  CImpl(const std::string& s_);
  ~CImpl();
};

// c.cpp

#include "c.h"
#include "cimpl.h"
#include <iostream>

C::C(const std::string& s_) : s(s_), p_(new CImpl(s_))
{
  std::cerr << "C::C() for " << s << std::endl;
}

C::~C()
{
  std::cerr << "C::~C() for " << s << std::endl;
}

// cimpl.cpp

#include <iostream>
#include "cimpl.h"

CImpl::CImpl(const std::string& s_) : s(s_)
{
  std::cerr << "CImpl::CImpl() for " << s << std::endl;
}

CImpl::~CImpl()
{
  std::cerr << "CImpl::~CImpl() for " << s << std::endl;
}