Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Bug: C++/CLI implement interface uses override
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

xMRi
Tomato Guru

Germany
315 Posts

Posted - Oct 12 2016 :  02:14:19 AM  Show Profile  Reply with Quote
When you implement an interface for C++/CLI VAX creates the virtual function with the keyword override. But this is wrong.

Implementing an interface in C++/CLI doesn't require the keyword override.If it is used you get a compiler error.

Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming

ChrisG
Whole Tomato Software

USA
299 Posts

Posted - Oct 12 2016 :  4:44:44 PM  Show Profile  Reply with Quote
Using a CLR Console Application project to test, I can see the behavior you are talking about. You say that the use of 'override' causes the compiler to complain, but I'm not sure what scenario would do that exactly. My tests so far have worked. (although I am not an expert at C++/CLI)

Is there a specific interface declaration that will reproduce this issue?

using namespace System;

interface struct MyInterface
{
	void f();
};

ref class MyClass : public MyInterface
{
public:
	virtual void f() override
	{
		Console::WriteLine(L"Hello World");
	}
};
Go to Top of Page

xMRi
Tomato Guru

Germany
315 Posts

Posted - Oct 14 2016 :  02:37:04 AM  Show Profile  Reply with Quote
No there is no special interface, that leads me into the errors
Your sample shows it. VS2015 gives me the following error:

1>ReportEngine.cpp(26): warning C4490: 'override': incorrect use of override specifier; 'Reporting::MyClass::f' does not match a base ref class method
1> ReportEngine.cpp(26): note: 'new' or 'override' are only allowed when a matching base method from a ref class exists
1> ReportEngine.cpp(26): note: Matching base method 'Reporting::MyInterface::f' is from an interface class (not a ref class)


Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000