Community discussion forum

Please help me!

Tags: c++ India
  • 2 years ago

    Hello,Idea [Idea]

    I'm Pravara, I'm trying to solve the diamond problem in C++ without using "virtual" inheritance. I tried to use member function pointers. but still i'm not able to access the function in base class i.e. ambiguity is still there. Please tell me whethher it is possible to solve this problem without using virtual is possible or not?

    and if it is possible then how it can be done?

  • 2 years ago

    Hi ,

    Would you tell more about diamond problem in C++ ? and about your specific problem ?

  • 2 years ago
    Just to clarify... by "Trying to solve the diamind problem", you mean some thing like this:

    4 classes "A", "B", "C" and "D".  B inherits from A, C inherits from A, D inherits from B and C.  D only contains one instance of A.



    The simple awnser is that if you actually want to do this with inheritance, then you must use "virtual" inheritance.  It was added to the language because this exact problem can't be solved without it.


    Times when you need to used diamond inheritance are very rare.
    Can you give a little more info on your reason for needing it?

    Regards









Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback