Cook Computing

Reducing Accessibility of Virtual Methods (or Not)

May 28, 2002 Written by Charles Cook

The suggested class in the previous posting relied on the fact that in C++ you can reduce the accessibility of a virtual method in a derived class:


class Parent
{
public:
  void virtual Foo() { };
};

class Child : public Parent
{
private:
  void Foo() { };
};

However this is not possible in Managed C++ if the classes are marked with __gc (and is incidentally also not possible in C#). Another example of how languages have to be distorted in the cause of interop with other .NET languages.