Multiple inheritance and destructors

  • Thread starter Christopher Benson-Manica
  • Start date
C

Christopher Benson-Manica

Okay, having purchased the excellent Josuttis book last night, I've
almost got my little streambuf subclass bit worked out. Now, though,
I'm faced with some issues with the destructors...

public TRFileStream : public TLSFile, public std::streambuf
{
...
};

The problem, I think, is that ~TLSFile is *not* virtual, but
~std::streambuf is. How can I reconcile these two destructors?
 
J

John Harrison

Christopher Benson-Manica said:
Okay, having purchased the excellent Josuttis book last night, I've
almost got my little streambuf subclass bit worked out. Now, though,
I'm faced with some issues with the destructors...

public TRFileStream : public TLSFile, public std::streambuf
{
...
};

The problem, I think, is that ~TLSFile is *not* virtual, but
~std::streambuf is. How can I reconcile these two destructors?

Not sure there is a problem with that. What problem are you actually seeing?

john
 
C

Christopher Benson-Manica

John Harrison said:
Not sure there is a problem with that. What problem are you actually seeing?

Well, with no destructor declared in the function, I'm told

Virtual function '_fastcall TWFileStream::~TWFileStream()' conflicts with base
class 'streambuf'

(note the Borland-specific __fastcall qualifier, which I perhaps
unwisely did not mention in my original post)

I get the same error if I attempt to specify a destructor like this:

__fastcall ~TWFileStream() {;} //or, alternatively
virtual __fastcall ~TWFileStream() {;}

And if I specify it thus (in an attempt to placate std::streambuf):

virtual ~TWFileStream() {;}

Virtual function 'TWFileStream::~TWFileStream()' conflicts with base class
'TLSFile'

Is this stupid Borland qualifier going to ruin what could otherwise be
a wonderful piece of code? I'd appreciate any ideas...
 
J

John Harrison

Christopher Benson-Manica said:
seeing?

Well, with no destructor declared in the function, I'm told

Virtual function '_fastcall TWFileStream::~TWFileStream()' conflicts with base
class 'streambuf'

(note the Borland-specific __fastcall qualifier, which I perhaps
unwisely did not mention in my original post)

I get the same error if I attempt to specify a destructor like this:

__fastcall ~TWFileStream() {;} //or, alternatively
virtual __fastcall ~TWFileStream() {;}

And if I specify it thus (in an attempt to placate std::streambuf):

virtual ~TWFileStream() {;}

Virtual function 'TWFileStream::~TWFileStream()' conflicts with base class
'TLSFile'

Is this stupid Borland qualifier going to ruin what could otherwise be
a wonderful piece of code? I'd appreciate any ideas...

Well I have no idea about the Borland bit (ask on a Borland newsgroup,
details from their community web page)but since TLSFile doesn't seem to have
been designed for inheritance perhaps you could recode

class TWFileStream : public std::streambuf
{
...
private:
TLSFile m_file;
};

Tedious since you'll have to wrap the entire TLSFile interface, but maybe
it'll work.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top