E
er
hi,
here's a rather open ended question. someone will probably ask me for
an example. i do have one, but it's specific to a particular narrow
field. i'll try to think of a more universal example. meanwhile here's
a generic example:
class A{virtual xxx membFun(yyy)=0;}//membFun impl in a derived class
class B{virtual xxx membFun(yyy)=0;}//membFun impl in a derived class
the interface is the same, and sometimes the following makes sense:
template<class T> fun1(cont T&){/*...*/};//T is A or B;
but A and B are slightly different in concept i.e. there is some fun2:
fun2(const A&){/*.../*};//but fun2(const B&) would not make sense.
is the above the right approach i.e. keep A and B separate? i'm quite
aware that we could also do
class Common{virtual xxx membFun(yyy)=0;};
class Aublic Common{virtual xxx membFun(yyy)=0;}
class Bublic Common{virtual xxx membFun(yyy)=0;}
fun1(const Common&){/*...*/}
fun2(const A&){/*...*/}
but have a feeling the is-a relation is not firmly established...
here's a rather open ended question. someone will probably ask me for
an example. i do have one, but it's specific to a particular narrow
field. i'll try to think of a more universal example. meanwhile here's
a generic example:
class A{virtual xxx membFun(yyy)=0;}//membFun impl in a derived class
class B{virtual xxx membFun(yyy)=0;}//membFun impl in a derived class
the interface is the same, and sometimes the following makes sense:
template<class T> fun1(cont T&){/*...*/};//T is A or B;
but A and B are slightly different in concept i.e. there is some fun2:
fun2(const A&){/*.../*};//but fun2(const B&) would not make sense.
is the above the right approach i.e. keep A and B separate? i'm quite
aware that we could also do
class Common{virtual xxx membFun(yyy)=0;};
class Aublic Common{virtual xxx membFun(yyy)=0;}
class Bublic Common{virtual xxx membFun(yyy)=0;}
fun1(const Common&){/*...*/}
fun2(const A&){/*...*/}
but have a feeling the is-a relation is not firmly established...