alexmherrmann
alexmherrmann

Reputation: 1073

Declaring any iostream related object in header throws error upon attempt to initialize

I have declared both a

class myclass
{
private:
  stringbuf* mbuf;
  iostream* mios;
};

in my class .h header file. however when I try to initialize them in my constructor like so:

myclass::myclass()
{
  mbuf = new stringbuf();
  mios = new iostream(mbuf);

}

it throws an error along the lines of:

invalid use of incomplete type 'std::stringbuf'

and then of course the iostream complains about not being able to use the stringbuf

Upvotes: 2

Views: 134

Answers (1)

dirkgently
dirkgently

Reputation: 111250

Did you include the appropriate headers i.e. <sstream> for stringbuf and <iostream> for iostream?

Upvotes: 7

Related Questions