keerthi

keerthi

  • NA
  • 4
  • 0

Inheritance

Dec 8 2007 1:09 PM

I have a doubt in Inheritance

1,I have a common class named - common
It has 3 child classes child1,child2,child3

2, I have a common class named - state

It has 3 child classes state1, state2, state3


I have a function  named xyz() in all the  3 childclasses of common, which I want to move to the parent class common.

The  function xyz( ) in child1 uses state1 class inside the function, creates object for state1 class.

The  function xyz( ) in child2 uses state2 class and creates object for state2 class.

The  function xyz( ) in child3 uses state3 class and creates object for state3 class.

But the procedure is same in all the function xyz()of the 3 childclasses, the only difference is usage of classes state1, state2, state3.

In this case how can I  put that xyz()function in parent class.so that all the 3 child classes can access the function from the parent class...

Is it necessary that I have to use Generic Inheritance....
could anybody throw some light on it?


Answers (3)