I have this class:
ref class Wrapper {
protected:
Native *pn;
public:
Wrapper(int val) { pn = new Native( val ); }
};
Then I derive from it:
ref class DerivedWrapper : public Wrapper{
public:
DerivedWrapper(int val) {pn = new DerivedNative(val); }
}
The compiler complains: error C2248 ‘ Wrapper::pn’ : cannot access private member declared in class ‘Wrapper’
The base class native pointer is clearly protected, and the derived class should have ready access to it. All my instincts tell me this should work. Is there something peculiar to ref classes?
I’m compiling with VS 2008 SP 1
Nativefrom the base class Assembly is not (directly) allowed and the compiler will implicitly change it to private. But you would get a warning if that happens. - PMF