|
You are up tomorrow!
You could have made it easier for yourself though:
Bottom ASS
Donkey ASS
Trendy IN
Killer:
ASSASSIN
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Please may I steal this to use in the Discworld MUD? I want to graffiti the assassins guild...
|
|
|
|
|
Help yourself!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Disregarding the flagrant violation of protocol, and the total disregard of the red text at the top of the forum, those of you who have programmed in C++, have you ever used protected and private inheritance? I've never had a use for it, but have been extremely curious about when they are handy. They are not in C# (from what I've read), but maybe I've overlooked something, and they are useful in ways I don't know? Your thoughts and experiences, to expand an undeveloped understanding...
|
|
|
|
|
I never used protected or private inheritance.
Anyway, I reckon they could be useful.
|
|
|
|
|
The first time I read about them (years ago), they made no sense to me. The last reading I did made them seem like protected inheritance made public members protected , and private inheritance made public members private in the derived class. I can see this maybe being useful in some situations, but am curious as to where that would be the case.
|
|
|
|
|
I suppose they could have use, for instance, in implementing a Facade design pattern.
|
|
|
|
|
All members of the base class get restricted to the inheritance type. So both public and protected members of the base class are now private in the derived class if using private inheritance. So any users of that derived class don't "see" the inheritance. As I said in my other post, I've never seen a good example of why this would be needed though
EDIT: Two words for clarity. Also private base class members are still not visible to the derived class iirc.
|
|
|
|
|
I'm not a regular C++ dev but I've never had a reason to use them so far. I've also never seen a good example of why they're useful that can't be solved in another way (e.g. composition). Whether you value it or not is up to you and the situation, but it's worth mentioning that private and protected inheritance breaks the Liskov Substitution Principle, and private inheritance breaks polymorphism in the inheritance hierarchy.
Honestly though, I'd love to see an example of either being useful.
|
|
|
|
|
Well,
If you ever get to work at a company with thousands of developers (or as a program manager) you'll quickly understand the value. They are a very useful tool for controlling the application binary interface[^].
Let's say that you create an awesome library called DoSomethingAwesome.lib and everybody at your company wants to use DoSomethingAwesome. They take your lib as a dependency and quickly integrate it into dozens of projects. They derive classes from your headers and extend them and now it's DoSomethingMoreAwesome.
Then your team changes some of the internals and DoSomethingAwesome is no longer compatible with DoSomethingMoreAwesome. In fact now dozens of other teams at the company are having to re-write parts of their code to accommodate for the changes in your lib. Paying software engineers is expensive and now this change has cost the company thousands of dollars.
The concept of protected and private inheritance is a useful tool that allows the library development team to control the public interfaces and keep a stable ABI. It's just a tool in the toolbox.
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you Very Much for this explanation! As I said before, I am in awe of your talents, and this is helpful for my understanding!
|
|
|
|
|
|
The abbreviation is overused, but lol!
|
|
|
|
|
(And also made me a bit sad, that we are overwriting the lives of other species to supposedly improve our own.)
|
|
|
|
|
Yeah,
David O'Neil wrote: we are overwriting the lives of other species to supposedly improve our own One of my old coworkers has a wife that was working as a research scientist at the Tulane National Primate Research Center |[^] and she would describe some of her research. They have over 5,000 primates, you have absolutely no idea... what she was telling me was worse than anything you can possibly even imagine.
Best Wishes,
-David Delaune
|
|
|
|
|
All one needs to do is recall images of live monkeys with the tops of their skulls removed and numerous wires implanted.
There's a reason that there are groups who are outraged by these practices are sometimes even provoked to mass-releases by attacking the labs. Those who condemn them - maybe if they had a look first, before the lab covered up the less PR-improving experiments.
Not just monkeys - much of animal testing is irrelevant. If we relied on its outcome, we'd consider aspiring toxic (cats) and chocolate toxic (dogs) - we'd make up for it with amanita phalloides as a tasty addition to our diet since it doesn't harm rabbits. That's a mushroom more commonly called "The Death Angel".
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
W∴ Balboos, GHB wrote: All one needs to do is recall images of live monkeys with the tops of their skulls removed and numerous wires implanted. I don't know how you knew that, but she also told me that the experiments required that the primates were conscious to get accurate data. I don't know how she could sleep at night after doing something like that. It's disgusting.
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: I don't know how you knew that, Pictures of that have been available for years (often showing up in donation requests from animal rights groups).
Animals deliberately crippled, typically spinal cord damage, for experiments. Vivisection is common.
Personally, I won't even wear leather as it's value-added to the slaughter-industry (and rather repulsive if you think about what it is).
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
|
A good example, but most cases I've come across caring about these kind of problems use delegates instead of inheritance. Delegates come with the additional advantage to keep what would otherwise be the base class entirely out of the API (i. e. the headers).
I. e. instead of putting this into your header:
class MyEncapsulatedBaseClass { public:
void doAwesomeStuff();
};
class MYAPI MyDerivedClass : private MyEncapsulatedBaseClass { public:
void doMoreAwsomeStuff(); };
you only put this in your header:
class MYAPI MyClass {
class MyEncapsulatedClass* delegate;
public:
void doMoreAwesomeStuff(); };
The advantage of the latter is that you can switch to a different encapsulated class or change the function and data members in that class without affecting the API delivered to your clients.
The only advantage of the former I can think of is, that with protected inheritance, that protection is not final, at least not for virtual member functions: another derived class can overide any protected virutal base function with a public one, making it accessible again! (Of course, if you want to retain that option, the question is why don't you use public inheritance to start with ? )
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Yep,
C++ has become such a feature-rich language. There are many tools in the programmers toolbox.
Best Wishes,
-David Delaune
|
|
|
|
|
You maybe used composition to define 'has-a' relations... that's the way C# preferred, so no private inheritance there...
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
You use inheritance when a derived type must implement the functionality of the base type.
- Public inheritance is used when the public functionality of the base type may be used by anyone.
- Protected inheritance is used when the public functionality of the base type may be used only by further-derived types.
- Private inheritance is used when the public functionality of the base type may not be used by further-derived types.
An example for private (or protected) inheritance might be a wrapper for the HANDLE object in Windows. A HANDLE wrapper may be constructed directly so its constructor must be public, but inside a File object you probably want only the File object (or its derived types) to be able to access the HANDLE.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Yes, they come very handy to define the degree of derivation freedom you want to let users for your interface elements.
Why the question ?
|
|
|
|
|
Rage wrote: Why the question ? Because I have never seen good examples for public and private derivation.
|
|
|
|