Virtual (private) C ++ function

I am using classes from dll in my C ++ project. Everything is working fine until ...

When I try to call a specific method (specified in the object browser), I get an error that this method is not a member of the namespace.

While researching, I noticed that this method is listed as "virtual void x () sealed."

Is there any way to make a call to such a function?

+4
source share
3 answers

In the future, for reference, I received a response from the corporate library support team. They placed a link to the following:

Managed C ++ and IDisposable I am writing code using the new Managed C ++ / CLI syntax, and I encountered this error:

error C2039: "Dispose": is not a member of "System :: IDisposable"

The code I started with this:

image->Dispose(); // image implements IDisposable 

which gave me the same compiler error, so I wanted to eliminate the class / namespace error, so I rewrote it like this:

 ((IDisposable ^)image)->Dispose(); 

This gave the above error. Hop!

Here's the fix:

use delete. Managed C ++ now hides Dispose () inside the finalizer. Just delete the object, it processes the rest. Freaky.

It really works !!!!

+3
source

Sealed in the C ++ CLI keyword (managed by C ++) specific for .NET, and not in C ++ at all.

sealed for a function means that you cannot override this method in a derived type.

sealed doesn't mean you can't call a function, I assume your function is private .

+2
source

I do not understand why this virtual and sealed should in itself prevent you from calling a function. According to MSDN , a sealed keyword is specifically for virtual methods.

Is there any additional information about this feature and how you use it?

+1
source

Source: https://habr.com/ru/post/1301233/