Hackerrank-Accessing Inherited Functions problem-Inheritance
#include< iostream > using namespace std; class A { public : A(){ callA = 0 ; } private : int callA; void inc(){ callA++; } protected : void func( int & a) { a = a * 2 ; inc(); } public : int getA(){ return callA; } }; class B { public : B(){ callB = 0 ; } private : int callB; void inc(){ callB++; } protected : void func( int & a) { a = a * 3 ; inc(); } public : int getB(){ return callB; } }; class C { public : C(){ callC = 0 ; } private : int callC; void inc(){ callC++; } protected : void func( int & a) { a =
Comments
Post a Comment