I think using an interface to change or modify the value of a member of class by another class, may be better solution. Here are an example of such design.
class IModifier {
virtual void Modify( int &x ) = 0;
};
class A {
private:
int x;
public:
void ModifyX( IModifier* pModifier)
{
pModifier->Modify(x);
}
}
class B : public IModifier {
public:
void Modify( int &x )
{
x = 10;
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment