Diamond problem is handled in some OOPS languages (eg. curl) by having the repeatedly inherited class as "shared"? I want to know how this works. Also, I want to know the role played by primary and secondary constructors in solving the diamond problem in these OOPS languages when shared strategy is used. Suppose there are 4 classes say A,B,C and D. Let the inheritance structure is B and C inherit A and D inherits both B and C. Each class has a variable say A has a, B has b, C has c and D has d. How does the object creation happens for each class?
How diamond problem in oops is solved using "shared" strategy?
290 views Asked by Kamalapriya Subramanian At
1
There are 1 answers
Related Questions in OOP
- How do I apply the interface concept with the base-class in design?
- Creating multiple instances of a class with different initializing values in Flutter
- System.InvalidCastException while inheriting a class
- How to add logging to an abstract class in php
- creating cutscenes using OOP and pygame
- What effect does the `virtual` modifier have on an interface member?
- How to pass the value of a function of one class to a function of another with the @property decorator
- Creating a C++ Class Instance for every server request?
- Dart OOP programming
- Containing Object Design
- Clean architecture/OOP and optimization: how to organize for classes with same logic
- How to get 5 LEVEL hierarchy users from database using PHP and MYSQL
- TypeError: unsupported operand type(s) for /: 'property' and 'complex'
- How can I refer to this metaclass inside a metaclass without specifying its name in the code?
- Why customed "-eq" do twice in Powershell?
Related Questions in DIAMOND-PROBLEM
- C++ multiple inheritance: avoiding reimplementation of a pure virtual function if the same function is already implemented in one of the parents
- Calling constructors of both parents in multiple inheritance in Python (general case)
- Inheriting specific attributes with multiple inheritance
- errors in my code that involve diamond pattern,
- Mixing Templates, Multiple Inheritance, and non-Default Constructor
- C++ Inheritance Diamond Problem: Preventing Duplicate Function Calls
- How to make (only) the main path virtual in the diamond problem
- Python Multiple Inheritance Diamond Problem
- Specify which base class function should be overriden in case of "triangle like" multiple inheritance pattern
- How to prevent a Nixpkgs overlay from being applied more than once?
- Diamond problem initialisation - default constructor ignored?
- C++, child with both parents having a same ancestor
- Does MathWorks Simulink prohibit multiple inheritance for system objects?
- constructor not Inheriting
- i can't wrap in flutter It was wrap before, I don't know what it looked like
Related Questions in PRIMARY-CONSTRUCTOR
- Enforcing Instance Creation of Record Types Through Specific Methods in C#
- Warning in property initialization in class with primary constructor
- How to initialise a Class using the C#12 Primary Constructor
- VS2022 Primary Constructor quick action not complete
- C# Primary constructor with body?
- Disable recommendation for primary constructors / IDE0290
- Should I create private properties for primary constructor parameters in C# 12?
- CS9110: Cannot use primary constructor parameter that has ref-like type inside an instance member. But why not?
- Why do C# 12 primary constructors execute in opposite order?
- Null checking with primary constructor in C# 12
- Kotlin. How to declare constant?
- Kotlin: How to use custom setters in primary constructor
- How to access primary constructor parameters inside secondary constructor kotlin
- How do I pass data from a variable into a constructor using the body of the variable?
- Init a property with a setter in a primary constructor in Kotlin
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Citing Wikipedia at https://en.wikipedia.org/wiki/Multiple_inheritance at the Curl bullet:
From here, without knowing Curl and only with the quote above and this, where it is stated that
Given
I imagine (I don't know for sure) that the coder is responsible to disambiguate the problem by specifying the qualified name of the constructor to run, when invoking a parent constructor from the D(B,C) subclass.
It looks like A has to be declared
shared, and when D is created, B runs a constructor that calls A (primary) constructor, C runs a constructor that calls A (secondary) constructor. The distinction between primary/secondary constructor call is automatic and transparent to the coder.As two A constructors are invoked, two A objects are created in memory, that is the A class is shared with two different subclasses, but there is not a single "shared" A object, but two independent ones (see also virtual/nonvirtual inheritance that is somehow related (C++).)
For what I've read for several different languages, it is almost always the coder that disambiguates the diamond problem with qualification. Languages just define different or similar schemes of giving an error, or having a criteria to choose one of the multiple ambiguous definitions, like specific search order in the inheritance chain. Some other languages don't even allow multiple inheritance, but in some of these you are allowed to extend functionality by some ohter means (like interfaces).