I got a class called Property (from external library == cannot be modified) that has private overloaded & operator. I use this class in another class as a property and (for sanity reasons) I'd like to return a reference to this property through the Get method. However I got the 'cannot access private member declared in class' error I cannot handle. Is there a way to walk around it - without making the Property public public.
// Some external class.
class Property
{
Property* operator&() const;
};
class MyClass
{
protected:
Property m_Property;
public:
// error C2248: 'Property::operator &' : cannot access private member declared in class 'Property'
const Property& GetProperty() const
{
return *& this->m_Property;
}
};