I can not seem to get this to compile with either gcc 3.4 or MSVC++ .NET
2003... (source follows first):
---= BEGIN MyStreamBuffer.h =---
// #IFDEF redundancy left out.
#include <streambuf>
template< class MyElem >
class MyStreamBuffer : public std::basic_streambuf< MyElem >
{
protected:
int_type overflow( int_type Data = traits_type::eof() );
};
--= END MyStreamBuffer.h =---
---= BEGIN MyStreamBuffer.cpp =---
#include "MyStreamBuffer.h"
template< class MyElem >
int_type MyStreamBuffer::overflow( int_type Data = traits_type::eof() )
{
return 0;
}
---= END MyStreamBuffer.cpp =---
And then I have a basic "int main( /* etc */ )" which merely constructs the
object (without 'new'). I know there's something wrong... as both compilers
I have tried fail to compile the source. I have tried (in the *.cpp file) to
use 'int_type' as "MyStreamBuffer< MyElem >::int_type to no avail.
*If* I leave the definition for the 'overflow' method within the definition
of the class it works no problem (that I can see). I would be very grateful
if someone had a reason why this can't be done... or just a very basic class
that is derived from std::basic_streambuf that has implementation and the
declaration separated by files.
Thank you!