473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Multiple inheritance and destructors

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?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #1
3 2135

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:c1**********@chessie.cirr.com...
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
Jul 22 '05 #2
John Harrison <jo*************@hotmail.com> spoke thus:
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...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #3

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:c1**********@chessie.cirr.com...
John Harrison <jo*************@hotmail.com> spoke thus:
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...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.


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
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ian McBride | last post by:
(was: delete() confusion) I have a class with multiple base classes. One of these base classes (base1) has its own new/delete operators and nothing else. Another base class (base 2) has a...
4
by: Warwick | last post by:
Hi I could use some help with inheritance and destructors. I have been following an example in a book and the example has lead to a situation which I have reduced to a contrived example that...
5
by: Mark | last post by:
When declaring a class that uses multiple inheritance, does the order used when listing the inheritance matter? I'm finding with my compiler (gcc 3.2.2) that my program seg faults when destructing...
4
by: Busin | last post by:
When a child class inherits from a base class, will the child class inherits everything of the base class, including all member variables and functions? Or is such inheritance "selective", like not...
2
by: ambar.shome | last post by:
Hi, See this code snippet.... class base1 { public: ~base1(){cout<<"base1 destructor called"<<endl;} };
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
3
by: dice | last post by:
This is a condensed version of a problem I came across today, can anyone explain what is going on? If the code below is run nothing will be output (in the original problem it was causing...
11
by: axel22 | last post by:
Please observe this simple model of multiple inheritance: void main() { class A { public: virtual void print() { cout << "A" << endl; }; class Support1 : virtual public A {
4
by: Christian Hackl | last post by:
Does the following code produce undefined behaviour? class Base { public: virtual ~Base(); /* ... */ }; class BaseWithNonVirtualDestructor
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.