C++ multiple inheritance function call ambiguity

前端 未结 2 1270
眼角桃花
眼角桃花 2020-11-29 02:50

I have a basic question related to multiple inheritance in C++. If I have a code as shown below:

struct base1 {
   void start() { cout << \"Inside base         


        
相关标签:
2条回答
  • 2020-11-29 03:31

    Sure!

    a.base1::start();
    

    or

    a.base2::start();
    
    0 讨论(0)
  • 2020-11-29 03:34
    a.base1::start();
    
    a.base2::start();
    

    or if you want to use one specifically

    class derived:public base1,public base2
    {
    public:
        using base1::start;
    };
    
    0 讨论(0)
提交回复
热议问题