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
{
public:
    virtual void F(){}
};

ref class Derived : Base
{
public:
    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 {} 
Advertisements

One thought on “No more implicit overriding for virtual functions of ref types

  1. Admiring the time and energy you put into your blog and in depth information you present.
    It’s awesome to come across a blog every once in a while that isn’t the same unwanted
    rehashed material. Wonderful read! I’ve saved your site
    and I’m adding your RSS feeds to my Google account.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s