Java is not allowing inheritance from multiple classes (still it allows inheritance from multiple interfaces.), I know it is very much inline with classic diamond problem. But my questions is why java is not allowing multiple inheritance like C++ when there is no ambiguity (and hence no chances of diamond problem) while inheriting from m...
I'm currently doing a full rewrite of an old library, and I'm not sure how to handle this situation (for the sake of being understood, all hail the bike analogy):
I have the following classes:
TBike - the bike itself
TBikeWheel - one of the bike's wheel
TBikeWheelFront and TBikeWheelBack, both inherits from TBikeWheel and then implemen...
I've run into a bit of a problem with my class hierarchy, in a WPF application. It's one of those issues where you have two inheritance trees merging together, and you can't find any logical way to make your inheritance work smoothly without multiple inheritance. I'm wondering if anyone has any bright ideas for getting this kind of syste...
I have a generic interface
public interface Consumer<E> {
public void consume(E e);
}
I have a class that consumes two types of objects, so I would like to do something like:
public class TwoTypesConsumer implements Consumer<Tomato>, Consumer<Apple>
{
public void consume(Tomato t) { ..... }
public void consume(Apple a) { ...
In Python, while designing a multiple inheritance subclass, should I place my app class first or language/framework/third-party class first?
Based on your experience which do you recommend:
1) My app class before a native or third party class
class MyClass(MyAppBaseClass, SomeLibraryOrNativePythonClass):
or
2) A native or third p...
Hi,
I was recently asked in an interview about object layout with virtual functions and multiple inheritance involved.
I explained it in context of how it is implemented without multiple inheritance involved (i.e. how the compiler generated the virtual table, insert a secret pointer to the virtual table in each object and so on).
It see...
Suppose you have two classes X & Y. You want to decorate those classes by adding attributes to the class to produce new classes X1 and Y1.
For example:
class X1(X):
new_attribute = 'something'
class Y1(Y):
new_attribute = 'something'
*new_attribute* will always be the same for both X1 and Y1. X & Y are not related in any meaning...
I've seen a few questions on this topic, but I haven't been able to find a definitive answer.
I would like to know the proper way to use old-style classes in a new Python code base. Let's say for example that I have two fixed classes, A and B. If I want to subclass A and B, and convert to new-style classes (A2 and B2), this works. Howe...
Hi ,
I have 3 interface classes IVideo , IAudio , IGPIO and three other classes that will implement those interface: Video_impl , Audio_impl , GPIO_impl.
Things is simple so far.
But then ,I want all those object to be singleton. Here are the questions:
Is it a good idea to abstract an Interface ISingleton , so that Video_impl , Audi...
I would like to know if it's possible to create a magic object that extends another magic object, (with PHP).
...
So, I'd like to hear what you all think about this.
I have a project where three different inheritance paths need to all implement another base class. This would be multiple inheritance and isn't allowed in C#. I am curious how I can implement this without code duplication.
EDIT: I don't own the three classes. The three classes are f...
I would like to know if there is anyway I can make a parent object with php, I have tried this:
new parent::__construct($var);
but it doesn't work and I get the following error in the php logs:
(..)PHP Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$'(..)
...
I have two distinct (no inheritance) interfaces:
IInvestable and IPricable
and two classes:
IndexClass and FundClass
that are stored in seperate tables in my DB.
IndexClass is IPriceable
FundClass is IPriceable and IInvestable.
I need a table to store prices against an IndexClass and a FundClass
I need a table to store that FundClass...
I have completely confused myself trying to design the necessary interfaces and abstracts to accomplish loading of domain entities that can be used by themselves as well as combined into an aggregate. Wow. That was a buzzword mouthful. Essentially, I have two objects that I would like to have base-type "load" functionality, but when t...
It's legal to do this in Java:
void spew(Appendable x)
{
x.append("Bleah!\n");
}
How can I do this (syntax not legal):
void spew(Appendable & Closeable x)
{
x.append("Bleah!\n");
if (timeToClose())
x.close();
}
I would like if possible to force callers to use objects that are both Appendable and Closea...
Hi all,
I'm facing problems with the design of a C++ library of mine. It is a library for reading streams that support a feature I haven't found on other "stream" implementations. It is not really important why I've decided to start writing it. The point is I have a stream class that provides two important behaviours through multiple in...
The example here doesn't make sense, but this is basically how I wrote my program in Python, and I'm now rewriting it in C++. I'm still trying to grasp multiple inheritance in C++, and what I need to do here is access A::a_print from main through the instance of C. Below you'll see what I'm talking about. Is this possible?
#include <ios...
I have an abstract base class (Comparable) with Date and Time virtually inheriting from it and a DateTime class v-inheriting from Date and Time.
My problem is this:
I was tasked with dynamically allocating an array of Comparables.
Comparable ** compArray;
compArray = new Comparable *[n]; // where n is user specified number of elements
...
I have a class whose functionality I'd like to depend on a set of plug-in policies. But, I'm not sure how to get a class to derive from an arbitrary number of classes.
The code below is an example of what I'm trying to achieve.
// insert clever boost or template trickery here
template< class ListOfPolicies >
class CMyClass : public L...
Hi,
I've been trying to make some custom exception classes for a C++ library I'm working on. These custom exceptions capture extra info, such as file,line number,etc, needed for debugging, if for some reason while testing an exception is not caught in the right place. However most people seem to recommend inheriting from the std::excepti...