JavaScript EditorDhtml editor     Free javascript download 



Main Page

The way private virtual functions are handled in derived classes has changed from Managed Extensions for C++ to Visual C++ 2005.

In Managed Extensions, the access level of a virtual function does not constrain its ability to be overridden within a derived class. This has changed. In the new syntax, a virtual function cannot override a base class virtual function that it cannot access. For example:

В CopyCode imageCopy Code
__gc class Foo {
   // inaccessible to a derived class …
   virtual void g();
};

__gc class Bar : public Foo {
public:
   // in Managed Extensions, ok: g() overrides Foo::g()
   // in new syntax, error: cannot override: Foo::g() is inaccessible …
   void g();
};

There is no real mapping of this sort of design onto the new syntax. One simply has to make the base class members accessible – that is, non-private. The inherited methods do not have to bear the same access. In this example, the least invasive change is to make the Foo member protected. This way the general program's access to the method through Foo is still prohibited,

В CopyCode imageCopy Code
ref class Foo {
protected:
   virtual void g();
};

ref class Bar : Foo {
public:
   virtual void g() override;
};

Note that the absence of the explicit virtual keyword in the base class, under the new syntax, generates a warning message.

See Also

Reference

Member Visibility

Concepts

Member Declarations within a Class or Interface



JavaScript EditorDhtml editor     Free javascript download 
casino games online