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?
233 views Asked by Kamalapriya Subramanian At
1
There are 1 answers
Related Questions in OOP
- Cabal sandbox is using a global dependency. Could not resolve
- Haskell lens: let binding of Traversal'
- How can I parse fixed-length, non-delimited integers with attoparsec?
- Pipeline-like operation using TChan
- compile-time vs. run-time cost of Hamlet templates
- Date-time package in haskell - error in the current one, can't find an analog
- How does one debug infinite recursion in Haskell?
- Force GHC using local files
- List with random numbers in Haskell
- Changes in other elements based on listbox selections in threepenny-gui
Related Questions in DIAMOND-PROBLEM
- Cabal sandbox is using a global dependency. Could not resolve
- Haskell lens: let binding of Traversal'
- How can I parse fixed-length, non-delimited integers with attoparsec?
- Pipeline-like operation using TChan
- compile-time vs. run-time cost of Hamlet templates
- Date-time package in haskell - error in the current one, can't find an analog
- How does one debug infinite recursion in Haskell?
- Force GHC using local files
- List with random numbers in Haskell
- Changes in other elements based on listbox selections in threepenny-gui
Related Questions in PRIMARY-CONSTRUCTOR
- Cabal sandbox is using a global dependency. Could not resolve
- Haskell lens: let binding of Traversal'
- How can I parse fixed-length, non-delimited integers with attoparsec?
- Pipeline-like operation using TChan
- compile-time vs. run-time cost of Hamlet templates
- Date-time package in haskell - error in the current one, can't find an analog
- How does one debug infinite recursion in Haskell?
- Force GHC using local files
- List with random numbers in Haskell
- Changes in other elements based on listbox selections in threepenny-gui
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).