You are here

Derive a new outer class which uses the inner class

Well, the job is nearly done. The class OG_constream doesn't extend its base class with new functionality. It only creates the buffer in the constructor and deletes the buffer in the destructor.
OG_constream::OG_constream() : ostream(new OG_constreambuf())
{
}

OG_constream::OG_constream(int i) : ostream(new OG_constreambuf(i))
{
}

OG_constream::~OG_constream()
{
  OG_constreambuf* pOG_constreambuf = (OG_constreambuf*) rdbuf();
  if (pOG_constreambuf)
    delete pOG_constreambuf;
}