473,394 Members | 1,770 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,394 software developers and data experts.

Multi Inheritance

Hello group !

I have a class interface (as .h ) but i don't have this class's source
file (as .cpp ). So i can't reach the source file..

class ServerBase {
public :
virtual void vfunc() const;
void nvfunc() const;
~ServerBase();
};

class ServerDer : public ServerBase {
public :
void vfunc() const;
~ServerDer();
};

I want to make nvfunc() and ~ServerBase functions virtual. how can i
do that?

Aug 3 '07 #1
1 1639
You can't. That is, you can't make the existing code call your nvfunc()
implementation. But you can obtain that effect for your own code, by
wrapping the class, e.g.

class MyServerBase
{
private:
virtual ServerBase& impl() = 0;
public:
virtual ~MyServerBase() {}
virtual void nvfunc() const { impl().nvfunc(); }
};

class MyServerDer: public MyServeBase
{
private:
ServerDer myImpl;
ServerDer& impl() { return myImpl; }
public:
virtual void nvfunc() cosnt { ... }
...
};
Maybe i think it can be, like this

class NewBase {
public :
virtual void vfunc() const = 0;
virtual void nvfunc() const = 0;
virtual void new_vfunc() const = 0;
virtual ~NewBase()
{
std::cout<<"NewBase::~NewBase()\n";
}
};

class Join : public NewBase , public ServerBase {
public :
void vfunc() const
{ std::cout<<"Join::vfunc() const\n"; }
void nvfunc() const
{ std::cout<<"Join::nvfunc() const\n"; }
void new_vfunc() const
{ std::cout<<"Join::new_vfunc const\n"; }
~Join()
{ std::cout<<"Join::~Join()\n"; }
};

L ke that but i don't understand explicitly? How can do that?

Aug 3 '07 #2

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

Similar topics

8
by: Gerhard Wolfstieg | last post by:
The following situation: class A0 { static A0 *a0; // something like this to publish the pointer public: A0() { a0 = this; } virtual ~A0(){}
1
by: Michael | last post by:
Hi, A piece of description about multi inheritance in ISO/ANSI C++ standard is as following: A class shall not be specified as a direct base class of a derived class more than once. ...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
2
by: bergel | last post by:
Hello, Regarding the variable layout with multi inheritance, I looked into a couple of C++ books but I was not able to find a descent answer. Let assume I have the following: class A{ int x;...
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...
27
by: Bernard Bourée | last post by:
Is there a way to overpass the impossibility of VN.NET to accept the multi heritage, that is to allow a class to inherit from TWO mother classes ? -- Bernard Bourée bernard@bouree.net
4
by: Joseph Paterson | last post by:
Hi all, I'm having some trouble with the following code (simplified to show the problem) class Counter { protected: int m_counter; }
5
by: Alexandre Badez | last post by:
Hye, I'm developing a little app, and I want to make multi heritage. My problem is that my both parent do have __slots__ define. So I've got something like: class foo(object): __slots__ = ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.