覆盖 C++/CLI 函数

Override C++/CLI functions

如何覆盖 C++/CLI 函数?

查看OpenCV的git,准确的说是defs.h, l. 503-506,可以发现:

CV_INLINE int cvRound( int value )
{
    return value;
}

所以函数已经为整数重载了,它不会隐式地将 int 转换为 double

这里是在Picturebox中覆盖OnPaint函数的例子。 如果你想重写函数,去MSDN了解可以重写的函数。那些可以覆盖的函数通常遵循 "OnXXXX( OOOOeventarg^ e)"

的名称
#pragma once

using namespace System::Drawing;
using namespace System::Windows::Forms;

ref class CustomPicturebox : public System::Windows::Forms::PictureBox
{
    public:
        CustomPicturebox();

    virtual void OnPaint(PaintEventArgs^ e) override {

        // Repeat the native behavior of .NET
        __super::OnPaint(e); 

        // Do whatever you want
        e->Graphics->FillRectangle(gcnew SolidBrush(Color::Blue), System::Drawing::RectangleF(0,0,50,50));
    }
};