Accessing Inherited Functions

  • + 0 comments

    here is my snippet: class D : public A, public B, public C {

    int val;
    public:
        //Initially val is 1
         D()
         {
            val = 1;
         }
    
    
         //Implement this function
         void update_val(int new_val)
         {
            while( val < new_val) {
                if(new_val % (2*val)==0){
                    this->A::func(val);
                } else if(new_val % (3*val)==0) {
                    this->B::func(val);
                }   else if ( new_val %(5*val)==0) {
                    this->C::func(val);
                } else {
                    break;
                }
            }
    
         }