No more implicit overriding for virtual functions of ref types

I was just going through my Code Project article on Function overriding in C++/CLI, and I noticed how the code snippets in the article indicated that if you don’t specify new or override on a derived class virtual function, override is assumed. Well, I was using an early Alpha compiler when I wrote that article and now, in the RTM version of the compiler, the compiler will not let you do that. For virtual functions of ref types, overriding is always explicit.

ref class Base
    virtual void F(){}

ref class Derived : Base
    virtual void F() {} // <-- error C4485

The right way would be to do one of the following :-

virtual void F() override {}
// or
virtual void F() new {} 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s