C ++虚拟(密封)函数 [英] C++ virtual (sealed) function
问题描述
我在我的C ++项目中使用dll中的类。一切正常,直到...
I am using classes from a dll in my C++ project. All is working fine, until...
当试图调用某个方法(在对象浏览器中列出)时,我得到一个错误,这种方法不是一个
When trying to call a certain method (listed in the object browser), I am getting an error that this method is not a member of the namespace.
调查后,我注意到这个方法被列为virtual void x()sealed。
Upon investigation, I noticed that this method is listed as "virtual void x() sealed".
有没有办法调用这样的函数?
Is there a way to make a call to such a function?
推荐答案
来自企业库支持团队的响应。他们发布了以下链接:
For future reference, I just received a response from the enterprise library support team. They posted a link to the following:
托管C ++和IDisposable
我使用新的Managed C ++ / CLI语法编写一些代码,错误:
Managed C++ and IDisposable I'm writing some code using the new Managed C++/CLI syntax and I ran into this error:
错误C2039:'Dispose':不是'System :: IDisposable'的成员
error C2039: 'Dispose' : is not a member of 'System::IDisposable'
我开始的代码是:
image->Dispose(); // image implements IDisposable
这给了我相同的编译器错误,所以我想要消除一个类/命名空间错误,所以我重写为这样:
which gave me the same compiler error, so I wanted to eliminate a class/namespace error so I rewrote it as this:
((IDisposable ^)image)->Dispose();
其中给出了上述错误。 Yikes!
Which gave the above error. Yikes!
这里是修复:
使用delete。托管C ++现在在终结器中隐藏Dispose()。只需删除对象,它处理其余的。 Freaky。
use delete. Managed C++ now hides Dispose() inside the finalizer. Just delete the object, it handles the rest. Freaky.
这真的很有效!
这篇关于C ++虚拟(密封)函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!