S
sreeni
I have a similar class hierarchy
class Base
{
public:
virtual get_method1();
virtual get_method2();
}
class derived1
ublic base
{
public:
friend class derived2;
virtual get_method1();
virtual get_method2();
void method(); // internally calls get_method1();get_method2()
}
class derived3
ublic base
{
public:
virtual get_method1();
virtual get_method2();
}
class derived2 : public derived3
{
public:
virtual get_method();
virtual get_method2();
private :
derived1* p;
}
i have to handle two scenarios
i ) i need to call derived1 function method from derived2 through
pointer p this can be achieved with current setup
p->method() which internally would call get_method1() and
get_method2() of derived1
ii) i need to call derived1 function method from derived2 through
pointer p
but method() of derived1 should call get_method1() and get_method2()
of derived2 obj
Please tell if its possible to do the same.
class Base
{
public:
virtual get_method1();
virtual get_method2();
}
class derived1
{
public:
friend class derived2;
virtual get_method1();
virtual get_method2();
void method(); // internally calls get_method1();get_method2()
}
class derived3
{
public:
virtual get_method1();
virtual get_method2();
}
class derived2 : public derived3
{
public:
virtual get_method();
virtual get_method2();
private :
derived1* p;
}
i have to handle two scenarios
i ) i need to call derived1 function method from derived2 through
pointer p this can be achieved with current setup
p->method() which internally would call get_method1() and
get_method2() of derived1
ii) i need to call derived1 function method from derived2 through
pointer p
but method() of derived1 should call get_method1() and get_method2()
of derived2 obj
Please tell if its possible to do the same.