I am creating a .net managed wrapper. All the code is in C++ and I am creating a wrapper using C++/CLI.
Some functions inside the C++ class are at protected level and hence I am not able to wrap those function. I keep on getting a “cannot access protected member declared in class error whenever I try to wrap the protected function.
Is there a workaround for this?
A protected method can only be called from within a class or its subclasses.
There’s no need to wrap a protected method, because it’s only intended to be called from within the class hierarchy in the first place. The application that uses the wrapper isn’t in the class hierarchy of either the C++ or C++/CLI classes.
Even if you were able to call the protected method from your wrapper class, who would be calling it? The method in the wrapper class would be declared protected as well, consumers of the wrapper class wouldn’t be able to call it.