VC++ 2005 Beta 2: warning C4490: 'override' : incorrect use of override specifier

A

Adriano Coser

Hello.

After I converted my .net code to the new VC2005 syntax I started to get
C4490 on my ExpandableObjectConverter subclass overrides. The GetProperties
method is no longer called by the PropertyGrid when I use my subclass as a
type converter.

Can anyone tell me what has changed? What's the correct way to override
GetProperties method? Here's the code for my class:

// ExpandableProperty.h
#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Diagnostics;

public ref class TExpandableProperty : public ExpandableObjectConverter
{
public:
TExpandableProperty();

virtual PropertyDescriptorCollection^
GetProperties(ITypeDescriptorContext^, Object^, Attribute^ attributes)
override { return GetProperties(); }
virtual PropertyDescriptorCollection^ GetProperties(Object^) override {
return GetProperties(); }
virtual PropertyDescriptorCollection^
GetProperties(ITypeDescriptorContext^, Object^) override { return
GetProperties(); }
virtual PropertyDescriptorCollection^ GetProperties() override { return
propertyCollection; }

virtual bool GetPropertiesSupported(ITypeDescriptorContext^) override {
return true; }
virtual bool GetPropertiesSupported() override { return true; }

bool AddProperty(PropertyDescriptor ^propertyDescriptor);

private:
PropertyDescriptorCollection ^propertyCollection;
};

// ExpandableProperty.cpp

#include "StdAfx.h"
#include ".\expandableproperty.h"
#using <mscorlib.dll>

//-----------------------------------------------------------

TExpandableProperty::TExpandableProperty()
{
propertyCollection = gcnew PropertyDescriptorCollection(nullptr);
}

//-----------------------------------------------------------

bool TExpandableProperty::AddProperty(PropertyDescriptor^
propertyDescriptor)
{
propertyCollection->Add(propertyDescriptor);
return true;
}

Thanks in advance for any help.

Regards,
Adriano.



AltoQi - Tecnologia Aplicada à Engenharia Adriano Coser Departamento de
Desenvolvimento Tel.: (48) 239-7000 ramal: 7069 e-mail: (e-mail address removed)
website: www.altoqi.com.br
 
J

James Park

I think if you just override:

virtual PropertyDescriptorCollection^ GetProperties(ITypeDescriptorContext^,
Object^, array<Attribute^>^) override

and

virtual bool GetPropertiesSupported(ITypeDescriptorContext^) override

it'll take care of the overloads as well. Also, there isn't a
GetProperties() overload that takes no arguments.
 
A

Adriano Coser

Thanks for your answer James.

Translating from de old syntax I declared the third parameter as
'Attribute^' instead of 'array<Attribute^>^' and I just didn't see this
error until your answer.

Regards,
Adriano.

AltoQi - Tecnologia Aplicada à Engenharia Adriano Coser Departamento de
Desenvolvimento Tel.: (48) 239-7000 ramal: 7069 e-mail: (e-mail address removed)
website: www.altoqi.com.br
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top