S
srinivasarao_moturu
class ABC
{
public :
virtual void operation1();
virtual void operation2();
virtual int GetValue();
virtual char GetValue();
virtual void SetValue(int);
virtual void SetValue(char);
}
class intABC : public ABC
{
public :
virtual void operation1();
virtual void operation2();
void SetValue(int);
int GetValue();
private:
int val;
}
class charABC : public ABC
{
public :
virtual void operation1();
virtual void operation2();
void SetValue(char);
char GetValue();
private :
char val;
}
class Controler
{
public :
//constructors and destructors
void somefunc() //this function handles container member
private :
vector<ABC*> val;
}
client Controler class manipulates ABC derived classes polymorphically
I feel, In the above design surely it is not following Lispov
substitution principle.
here ABC is a fatty interface since intABC does not require char
version of get/set members
and charABC does not require int version of get/set members.
If I remove Get/Set members from ABC class and put int versions in
intABC and char versions in charABC then I have to use downcasting to
call specific versions.
so is there a good design to remove fatty interface from the ABC and at
the same time i should not use downcasting and another constraint is I
should use ABC polymorphically?
With Regards,
Sri.
{
public :
virtual void operation1();
virtual void operation2();
virtual int GetValue();
virtual char GetValue();
virtual void SetValue(int);
virtual void SetValue(char);
}
class intABC : public ABC
{
public :
virtual void operation1();
virtual void operation2();
void SetValue(int);
int GetValue();
private:
int val;
}
class charABC : public ABC
{
public :
virtual void operation1();
virtual void operation2();
void SetValue(char);
char GetValue();
private :
char val;
}
class Controler
{
public :
//constructors and destructors
void somefunc() //this function handles container member
private :
vector<ABC*> val;
}
client Controler class manipulates ABC derived classes polymorphically
I feel, In the above design surely it is not following Lispov
substitution principle.
here ABC is a fatty interface since intABC does not require char
version of get/set members
and charABC does not require int version of get/set members.
If I remove Get/Set members from ABC class and put int versions in
intABC and char versions in charABC then I have to use downcasting to
call specific versions.
so is there a good design to remove fatty interface from the ABC and at
the same time i should not use downcasting and another constraint is I
should use ABC polymorphically?
With Regards,
Sri.