We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Here my Soln:-
class D : public A,public B,public C
{
public:
int val;
//Initially val is 1
D()
{
val=1;
}
//Implement this function
void update_val(int new_val)
{
int a = new_val;
while ( a %2 == 0)
{
a = a/2;
A::func(val);
}
while ( a % 3 == 0)
{
a = a/3;
B::func(val);
}
while ( a % 5 == 0)
{
a = a/5;
C::func(val);
}
}
//For Checking Purpose
void check(int); //Do not delete this line.
};
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Accessing Inherited Functions
You are viewing a single comment's thread. Return to all comments →
Here my Soln:- class D : public A,public B,public C { public: int val;
};