覆盖C ++ / CLI函数

时间:2015-06-12 11:50:35

标签: c++-cli

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

2 个答案:

答案 0 :(得分:1)

看看OpenCV的git,确切地说是defs.h, l. 503-506,你可以找到:

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

因此该函数已经为整数重载,并且它不会隐式地将int转换为double

答案 1 :(得分:1)

以下是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));
    }
};