Lets say that I have a class A with a private pointer to some data and a protected accessor for that data.
class A
{
...
protected:
void * GetData() const { return m_Data; }
private:
void * m_Data;
};
Then I have two derived classes B and C. Both have functions which take a reference to the other type.
class B
{
public:
...
void SomeFunc(C& c);
}
class C
{
public:
...
void SomeFunc(B& b);
}
I want to be able to use the derived accessor function for each type from within each function, but I don't want it to be available anywhere other than the base class or the derived classes.
void B::SomeFunc(C& c)
{
void * Data = c.GetData(); // want to do this
}
void C::SomeFunc(B& b)
{
void * Data = b.GetData(); // want to do this
}
void Func(B& b, C& b)
{
void * Data = c.GetData(); // don't want to do this
void * Data = b.GetData(); // don't want to do this
}
Obviously, I cannot do this the way that I was hoping with the protected accessor, but I don't want the accessor to be public. Is there anything else that I can do? Thanks for the help.
-Matthew
[edited by - matthew02 on October 30, 2002 10:37:15 AM]