stringbuf Constructor Poblem

closed account (zb0S216C)
I'm learning about stringbufs, and filebufs. However, I ran into a problem when defining a stringbuf instance.

stringbuf Constructors:

explicit stringbuf ( ios_base::openmode which = ios_base::in | ios_base::out );
explicit stringbuf ( const string& str, ios_base::openmode which = ios_base::in | ios_base::out );


When I use the second constructor, I receive an error saying: incomplete type is not allowed

This is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

using std::stringbuf;
using std::string;
using std::ios_base;

int main( )
{
    string Buffer( "Sample String" );
    stringbuf StringBuffer( Buffer ); // Error: incomplete type is not allowed

    return 0;
}


Any ideas?

Also, is it worth learning about stringbuf, filebuf, and streambuf?
Just add #include <sstream> . Whatever iostream inclues only forward declares stringbuf, but doesn't define it.
closed account (zb0S216C)
Thanks, Hamsterman.
Topic archived. No new replies allowed.