error: request for member is ambiguous c++;

  ambiguity, c++, class, methods

I’ve already reviewed several similar questions at StackOverflow, but nothing helps. I can’t understand why the keyword using in my class NetflixCanada does not resolve the ambiguity.

What I want to achieve:
to access 2nd time a private method from NetflixUkraine class.

Anyway, this is the code:


    #include <iostream>
    using namespace std;
    
    void greetings(){
        cout << "e[1mHi! This is a Netflix country review:e[0mn";
    }
    
    class NetflixUkraine {
        private:
        string mostPplrBrowserFrNTflx;
    
        public:
        string countryName; 
        int amountMedia = 5000;
        void uniqueMedia(){
            cout << "We have john Wick IIn";
        }
        
            void setBrowser(string amostPplrBrowserFrNTflx){
            if (amostPplrBrowserFrNTflx == "Chrome" || amostPplrBrowserFrNTflx == "Firefox" || 
            amostPplrBrowserFrNTflx == "Safari" || amostPplrBrowserFrNTflx == "Opera"){
    
                mostPplrBrowserFrNTflx = amostPplrBrowserFrNTflx;
            }
    
            else {
                mostPplrBrowserFrNTflx = "nCannot define a web browser!n";
            }
            }
    
    
            string getBrowser(){
                return mostPplrBrowserFrNTflx;
            }
    };
    
    class NetflixUS: public NetflixUkraine { 
                    //inheritancing from the previous class
                    //public is not needed for struct
    };
    
    class NetflixPoland: public NetflixUkraine { 
       public:
        void uniqueMedia(){
            cout << "We have john Wick II and IIIn"; //method overriding
        }
       
    
       string doPolesLoveNtflx(bool answer){ //extending inheritance    
           if (answer == 1){
                return "Poles love Netflix";
           }
           else{
                return "Poles don't love Netflix";
           }
       }
    };
    
    class NetflixCanada: public NetflixUkraine, public NetflixPoland{
        public:
//issue is here
        using NetflixUkraine::setBrowser;
    };
    
    int main()
    {
        greetings();
    
        //printing output
        NetflixUkraine library1;
        library1.countryName = "Ukraine";
        cout<< library1.countryName<<endl << library1.amountMedia << endl;
        library1.uniqueMedia(); //printing out the unique media
    
        NetflixUS library2;
        library2.countryName = "nUS";
        cout << library2.countryName <<endl<< library2.amountMedia<< endl;
        library2.uniqueMedia();
    
        NetflixPoland library3;
    library3.countryName = "nPoland";
    cout << library3.countryName<< endl;
    library3.uniqueMedia();
    cout << library3.doPolesLoveNtflx(true) << endl;
    
    //adding a fav browser for watching Netflix

//issue is here
        library3.setBrowser("Chrome");
        cout << "most popular browser for watching Netflix: " << library3.getBrowser() << endl;
    
        NetflixCanada library4;
        library4.NetflixUkraine::setBrowser ("Chrome");
    
        return 0;
    }

Output:


[12inheritance.cpp 2020-10-10 11:41:07.556]
,,12inheritance.cpp:65:7: warning: direct base ‘NetflixUkraine’ inaccessible in ‘NetflixCanada’ due to ambiguity
   65 | class NetflixCanada: public NetflixUkraine, public NetflixPoland{
      |       ^~~~~~~~~~~~~
12inheritance.cpp: In function ‘int main()’:
12inheritance.cpp:96:30: error: ‘NetflixUkraine’ is an ambiguous base of ‘NetflixCanada’
   96 |     library4.NetflixUkraine::setBrowser ("Chrome");
      |                              ^~~~~~~~~~

Source: Windows Questions C++

LEAVE A COMMENT